Author: tilman
Date: Mon Feb 12 16:54:09 2018
New Revision: 1824025

URL: http://svn.apache.org/viewvc?rev=1824025&view=rev
Log:
PDFBOX-4071: use of the relational operators < and > in compareTo methods is 
verbose and error-prone and no longer recommended (Effective Java 2018, p69); 
remove super()

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObjectKey.java
    
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriterXRefEntry.java

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObjectKey.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObjectKey.java?rev=1824025&r1=1824024&r2=1824025&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObjectKey.java 
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObjectKey.java 
Mon Feb 12 16:54:09 2018
@@ -98,29 +98,12 @@ public class COSObjectKey implements Com
     @Override
     public int compareTo(COSObjectKey other)
     {
-        if (getNumber() < other.getNumber())
+        int result = Long.compare(getNumber(), other.getNumber());
+        if (result == 0)
         {
-            return -1;
-        }
-        else if (getNumber() > other.getNumber())
-        {
-            return 1;
-        }
-        else
-        {
-            if (getGeneration() < other.getGeneration())
-            {
-                return -1;
-            }
-            else if (getGeneration() > other.getGeneration())
-            {
-                return 1;
-            }
-            else
-            {
-                return 0;
-            }
+            return Integer.compare(getGeneration(), other.getGeneration());
         }
+        return result;
     }
 
 }

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriterXRefEntry.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriterXRefEntry.java?rev=1824025&r1=1824024&r2=1824025&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriterXRefEntry.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriterXRefEntry.java
 Mon Feb 12 16:54:09 2018
@@ -48,15 +48,7 @@ public class COSWriterXRefEntry implemen
     {
         if (obj != null)
         {
-            if (getKey().getNumber() < obj.getKey().getNumber())
-            {
-                return -1;
-            }
-            else if (getKey().getNumber() > obj.getKey().getNumber())
-            {
-                return 1;
-            }
-            return 0;
+            return Long.compare(getKey().getNumber(), 
obj.getKey().getNumber());
         }
         return -1;
     }
@@ -140,7 +132,6 @@ public class COSWriterXRefEntry implemen
      */
     public COSWriterXRefEntry(long start, COSBase obj, COSObjectKey keyValue)
     {
-        super();
         setOffset(start);
         setObject(obj);
         setKey(keyValue);


Reply via email to