Improved code readability
[sixth-3d.git] / src / main / java / eu / svjatoslav / sixth / e3d / gui / TextPointer.java
index 67291f5..91cd6e6 100755 (executable)
@@ -4,6 +4,8 @@
  */
 package eu.svjatoslav.sixth.e3d.gui;
 
+import static java.lang.Integer.compare;
+
 /**
  * A pointer to a character in a text using row and column.
  * <p>
@@ -49,20 +51,32 @@ public class TextPointer implements Comparable<TextPointer> {
         return result;
     }
 
+    /**
+     * Compares this pointer to another pointer.
+     *
+     * @param textPointer The pointer to compare to.
+     * @return <ul>
+     *     <li>-1 if this pointer is smaller than the argument pointer.</li>
+     *     <li>0 if they are equal.</li>
+     *     <li>1 if this pointer is bigger than the argument pointer.</li>
+     *     </ul>
+     */
     @Override
     public int compareTo(final TextPointer textPointer) {
 
-        if (textPointer.row > row)
+        if (row < textPointer.row)
             return -1;
-        if (textPointer.row < row)
+        if (row > textPointer.row)
             return 1;
 
-        return Integer.compare(column, textPointer.column);
-
+        return compare(column, textPointer.column);
     }
 
     /**
-     * Checks if this pointer is between the specified pointers.
+     * Checks if this pointer is between the argument pointers.
+     * <p>
+     * This pointer is considered to be between the pointers if it is bigger or equal to the start pointer
+     * and smaller than the end pointer.
      *
      * @param start The start pointer.
      * @param end   The end pointer.