Skip to content

Commit

Permalink
PDFBOX-5660: use Objects.equals(), by Axel Howind
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1913597 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
THausherr committed Nov 5, 2023
1 parent 9fb5c98 commit 8b5de4f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.Map;
import java.util.Objects;
import java.util.WeakHashMap;

import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -103,15 +104,15 @@ public boolean equals(Object obj)
return false;
}
final TilingPaintParameter other = (TilingPaintParameter) obj;
if (this.matrix != other.matrix && (this.matrix == null || !this.matrix.equals(other.matrix)))
if (!Objects.equals(this.matrix, other.matrix))
{
return false;
}
if (this.patternDict != other.patternDict && (this.patternDict == null || !this.patternDict.equals(other.patternDict)))
if (!Objects.equals(this.patternDict, other.patternDict))
{
return false;
}
if (this.colorSpace != other.colorSpace && (this.colorSpace == null || !this.colorSpace.equals(other.colorSpace)))
if (!Objects.equals(this.colorSpace, other.colorSpace))
{
return false;
}
Expand Down Expand Up @@ -140,7 +141,7 @@ public boolean equals(Object obj)
LOG.debug("Couldn't convert color to RGB - treating as not equal", ex);
return false;
}
return !(this.xform != other.xform && (this.xform == null || !this.xform.equals(other.xform)));
return Objects.equals(this.xform, other.xform);
}

@Override
Expand Down
5 changes: 3 additions & 2 deletions pdfbox/src/main/java/org/apache/pdfbox/text/TextPosition.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.pdfbox.pdmodel.font.PDFont;
Expand Down Expand Up @@ -891,15 +892,15 @@ public boolean equals(Object o)
{
return false;
}
if (textMatrix != null ? !textMatrix.equals(that.textMatrix) : that.textMatrix != null)
if (!Objects.equals(textMatrix, that.textMatrix))
{
return false;
}
if (!Arrays.equals(charCodes, that.charCodes))
{
return false;
}
return font != null ? font.equals(that.font) : that.font == null;
return Objects.equals(font, that.font);

// If changing this method, do not compare mutable fields (PDFBOX-4701)
}
Expand Down

0 comments on commit 8b5de4f

Please sign in to comment.