Source:
<code>public void rotate(int degree) { Validate.isTrue(degree % 90 == 0 && degree > 0 && degree < 360, "Only rotations by 90, 180 and 270 degree are supported"); ArrayList<Entry> newIDFData = new ArrayList<>(); Iterator<Entry> it = IFD.iterator(); while (it.hasNext()) { newIDFData.add(it.next()); } short orientation = TIFFBaseline.ORIENTATION_TOPLEFT; Entry orientationEntry = IFD.getEntryById(TIFF.TAG_ORIENTATION); if (orientationEntry != null) { orientation = ((Number) orientationEntry.getValue()).shortValue(); newIDFData.remove(orientationEntry); } int steps = degree / 90; for (int i = 0; i < steps; i++) { switch (orientation) { case TIFFBaseline.ORIENTATION_TOPLEFT: orientation = TIFFExtension.ORIENTATION_RIGHTTOP; break; case TIFFExtension.ORIENTATION_TOPRIGHT: orientation = TIFFExtension.ORIENTATION_RIGHTBOT; break; case TIFFExtension.ORIENTATION_BOTRIGHT: orientation = TIFFExtension.ORIENTATION_LEFTBOT; break; case TIFFExtension.ORIENTATION_BOTLEFT: orientation = TIFFExtension.ORIENTATION_LEFTTOP; break; case TIFFExtension.ORIENTATION_LEFTTOP: orientation = TIFFExtension.ORIENTATION_TOPRIGHT; break; case TIFFExtension.ORIENTATION_RIGHTTOP: orientation = TIFFExtension.ORIENTATION_BOTRIGHT; break; case TIFFExtension.ORIENTATION_RIGHTBOT: orientation = TIFFExtension.ORIENTATION_BOTLEFT; break; case TIFFExtension.ORIENTATION_LEFTBOT: orientation = TIFFBaseline.ORIENTATION_TOPLEFT; break; } } newIDFData.add(new TIFFEntry(TIFF.TAG_ORIENTATION, (short) orientation)); <START> IFD = new AbstractDirectory(newIDFData) { <END> }; }</code><technical_language>Sorry, missed this time, public com.twelvemonkeys.imageio.metadata.tiff.IFD class, instead of anonymous class</technical_language>

Target:
public void rotate(int degree) { Validate.isTrue(degree % 90 == 0 && degree > 0 && degree < 360, "Only rotations by 90, 180 and 270 degree are supported"); ArrayList<Entry> newIDFData = new ArrayList<>(); Iterator<Entry> it = IFD.iterator(); while (it.hasNext()) { newIDFData.add(it.next()); } short orientation = TIFFBaseline.ORIENTATION_TOPLEFT; Entry orientationEntry = IFD.getEntryById(TIFF.TAG_ORIENTATION); if (orientationEntry != null) { orientation = ((Number) orientationEntry.getValue()).shortValue(); newIDFData.remove(orientationEntry); } int steps = degree / 90; for (int i = 0; i < steps; i++) { switch (orientation) { case TIFFBaseline.ORIENTATION_TOPLEFT: orientation = TIFFExtension.ORIENTATION_RIGHTTOP; break; case TIFFExtension.ORIENTATION_TOPRIGHT: orientation = TIFFExtension.ORIENTATION_RIGHTBOT; break; case TIFFExtension.ORIENTATION_BOTRIGHT: orientation = TIFFExtension.ORIENTATION_LEFTBOT; break; case TIFFExtension.ORIENTATION_BOTLEFT: orientation = TIFFExtension.ORIENTATION_LEFTTOP; break; case TIFFExtension.ORIENTATION_LEFTTOP: orientation = TIFFExtension.ORIENTATION_TOPRIGHT; break; case TIFFExtension.ORIENTATION_RIGHTTOP: orientation = TIFFExtension.ORIENTATION_BOTRIGHT; break; case TIFFExtension.ORIENTATION_RIGHTBOT: orientation = TIFFExtension.ORIENTATION_BOTLEFT; break; case TIFFExtension.ORIENTATION_LEFTBOT: orientation = TIFFBaseline.ORIENTATION_TOPLEFT; break; } } newIDFData.add(new TIFFEntry(TIFF.TAG_ORIENTATION, (short) orientation)); IFD = new IFD(newIDFData); }