class GridPosition {

    final int x;

    final int y;

    GridPosition(final int x, final int y) {
        this.x = x;
        this.y = y;
    }

    /*
     * This equals method is of deliberately narrow scope (only allows comparison with another GridPosition) to increase
     * readability. In general, one should provide a full implementation of Object.equals(Object obj) and a
     * corresponding implementation of Object.hashCode(). See
     *
     * https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#equals(java.lang.Object)
     *
     * and
     *
     * https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#hashCode()
     *
     * for more information.
     */
    boolean equals(final GridPosition gridPosition) {
        return this.x == gridPosition.x && this.y == gridPosition.y;
    }

}

@@ -151,595 +151,460 @@
     
-/*%0A     * This equals method is of deliberately narrow scope (only allows comparison with another GridPosition) to increase%0A     * readability. In general, one should provide a full implementation of Object.equals(Object obj) and a%0A     * corresponding implementation of Object.hashCode(). See
+@Override%0A    public int hashCode() %7B%0A        final int prime = 31;%0A        int result = 1;%0A        result = prime * result + x;%0A        result = prime * result + y;%0A        return result;
 %0A    
- *
+%7D%0A
 %0A    
- * https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#equals(java.lang.Object)
+@Override%0A    public boolean equals(Object obj) %7B
 %0A     
-*%0A
    
-  * and
+if (this == obj) %7B
 %0A     
-*%0A
+  
      
-* https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#hashCode()
+return true;%0A        %7D else if (obj == null %7C%7C getClass() != obj.getClass()) %7B
 %0A     
-*%0A
      
-* for more information.%0A     */%0A    boolean equals(final GridPosition g
+  return false;%0A        %7D else if (x != ((GridPosition) obj).x %7C%7C y != ((G
 ridP
@@ -611,16 +611,23 @@
 osition)
+obj).y)
  %7B%0A     
@@ -633,74 +633,82 @@
     
+ 
+   
 return 
-this.x == gridPosition.x && this.y == gridPosition.y;%0A
+false;%0A        %7D else %7B%0A            return true;%0A    
     %7D%0A
+    %7D
 %0A%7D%0A

improve equals for GridPosition