Skip to content

Commit

Permalink
PDFBOX-5703: use comparison operators for enums, as suggested by Axel…
Browse files Browse the repository at this point in the history
… Howind

git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1913203 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
THausherr committed Oct 22, 2023
1 parent 7285d73 commit 3dc3a02
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,11 @@ public boolean equals(Object object)
if (object instanceof CharStringCommand)
{
CharStringCommand that = (CharStringCommand) object;
if (type1KeyWord != null && type1KeyWord.equals(that.getType1KeyWord()))
if (type1KeyWord != null && type1KeyWord == that.getType1KeyWord())
{
return true;
}
if (type2KeyWord != null && type2KeyWord.equals(that.getType2KeyWord()))
if (type2KeyWord != null && type2KeyWord == that.getType2KeyWord())
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,14 @@ public static PDImageXObject createFromFileByContent(File file, PDDocument doc)
throw new IllegalArgumentException("Image type not supported: " + file.getName());
}

if (fileType.equals(FileType.JPEG))
if (fileType == FileType.JPEG)
{
try (FileInputStream fis = new FileInputStream(file))
{
return JPEGFactory.createFromStream(doc, fis);
}
}
if (fileType.equals(FileType.TIFF))
if (fileType == FileType.TIFF)
{
try
{
Expand All @@ -311,7 +311,7 @@ public static PDImageXObject createFromFileByContent(File file, PDDocument doc)
fileType = FileType.PNG;
}
}
if (fileType.equals(FileType.BMP) || fileType.equals(FileType.GIF) || fileType.equals(FileType.PNG))
if (fileType == FileType.BMP || fileType == FileType.GIF || fileType == FileType.PNG)
{
BufferedImage bim = ImageIO.read(file);
return LosslessFactory.createFromImage(doc, bim);
Expand Down Expand Up @@ -349,11 +349,11 @@ public static PDImageXObject createFromByteArray(PDDocument document, byte[] byt
throw new IllegalArgumentException("Image type not supported: " + name);
}

if (fileType.equals(FileType.JPEG))
if (fileType == FileType.JPEG)
{
return JPEGFactory.createFromByteArray(document, byteArray);
}
if (fileType.equals(FileType.PNG))
if (fileType == FileType.PNG)
{
// Try to directly convert the image without recoding it.
PDImageXObject image = PNGConverter.convertPNGImage(document, byteArray);
Expand All @@ -362,7 +362,7 @@ public static PDImageXObject createFromByteArray(PDDocument document, byte[] byt
return image;
}
}
if (fileType.equals(FileType.TIFF))
if (fileType == FileType.TIFF)
{
try
{
Expand All @@ -377,7 +377,7 @@ public static PDImageXObject createFromByteArray(PDDocument document, byte[] byt
fileType = FileType.PNG;
}
}
if (fileType.equals(FileType.BMP) || fileType.equals(FileType.GIF) || fileType.equals(FileType.PNG))
if (fileType == FileType.BMP || fileType == FileType.GIF || fileType == FileType.PNG)
{
ByteArrayInputStream bais = new ByteArrayInputStream(byteArray);
BufferedImage bim = ImageIO.read(bais);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ public RenderState getRenderState(RenderDestination destination)
COSDictionary usage = dict.getCOSDictionary(COSName.USAGE);
if (usage != null)
{
if (RenderDestination.PRINT.equals(destination))
if (RenderDestination.PRINT == destination)
{
COSDictionary print = usage.getCOSDictionary(COSName.PRINT);
state = print == null ? null : print.getCOSName(COSName.PRINT_STATE);
}
else if (RenderDestination.VIEW.equals(destination))
else if (RenderDestination.VIEW == destination)
{
COSDictionary view = usage.getCOSDictionary(COSName.VIEW);
state = view == null ? null : view.getCOSName(COSName.VIEW_STATE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public boolean isGroupEnabled(PDOptionalContentGroup group)
//i.e. OCProperties/Configs

PDOptionalContentProperties.BaseState baseState = getBaseState();
boolean enabled = !baseState.equals(BaseState.OFF);
boolean enabled = baseState != BaseState.OFF;
//TODO What to do with BaseState.Unchanged?

if (group == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ protected void showType3Glyph(Matrix textRenderingMatrix, PDType3Font font, int
{
PDGraphicsState state = getGraphicsState();
RenderingMode renderingMode = state.getTextState().getRenderingMode();
if (!RenderingMode.NEITHER.equals(renderingMode))
if (RenderingMode.NEITHER != renderingMode)
{
super.showType3Glyph(textRenderingMatrix, font, code, displacement);
}
Expand Down Expand Up @@ -1828,7 +1828,7 @@ private TransparencyGroup(PDTransparencyGroup form, boolean isSoftMask, Matrix c
private BufferedImage create2ByteGrayAlphaImage(int width, int height)
{
// gray + alpha
int[] bandOffsets = new int[] {1, 0};
int[] bandOffsets = {1, 0};
int bands = bandOffsets.length;

// Color Model used for raw GRAY + ALPHA
Expand Down Expand Up @@ -2001,7 +2001,7 @@ private boolean isHiddenOCG(PDPropertyList propertyList)
return true;
}
}
else if (RenderState.OFF.equals(printState))
else if (RenderState.OFF == printState)
{
return true;
}
Expand Down

0 comments on commit 3dc3a02

Please sign in to comment.