final 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;
    }

}

@@ -157,595 +157,434 @@
     
-/*%0A     * This equals method is of deliberately narrow scope (only allows comparison with another GridPosition) to increase
+@Override%0A   public int hashCode() %7B%0A      final int prime = 31;%0A      int result = 1;
 %0A     
-*
  re
-adability. In general, one should provide a full implementation of Object.equals(Object obj) and a%0A     * corresponding implementation of Object.hashCode(). See
+sult = 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)%0A     *%0A     * and%0A     *%0A     * https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#hashCode()%0A     *%0A     * for more information.%0A     */%0A    boolean equals(final GridPosition g
+@Override%0A   public boolean equals(Object obj) %7B%0A      if (this == obj) %7B%0A         return true;%0A      %7D else if (obj == null %7C%7C getClass() != obj.getClass()) %7B%0A         return false;%0A      %7D else if (x != ((GridPosition) obj).x %7C%7C y != ((G
 ridP
@@ -591,19 +591,27 @@
 osition)
+obj).y)
  %7B%0A
+ 
         
@@ -621,63 +621,60 @@
 urn 
-this.x == gridPosition.x && this.y == gridPosition.y;%0A 
+false;%0A      %7D else %7B%0A         return true;%0A      %7D%0A
    %7D

Update GridPosition equals and implement hashCode