Example #1
0
 /** Two objects that are equal are required to return the same hashCode. */
 public void testHashCode() {
   CategoryAnchor a1 = CategoryAnchor.START;
   CategoryAnchor a2 = CategoryAnchor.START;
   assertTrue(a1.equals(a2));
   int h1 = a1.hashCode();
   int h2 = a2.hashCode();
   assertEquals(h1, h2);
 }
Example #2
0
 /**
  * Returns <code>true</code> if this object is equal to the specified object, and <code>false
  * </code> otherwise.
  *
  * @param obj the other object.
  * @return A boolean.
  */
 @Override
 public boolean equals(Object obj) {
   if (this == obj) {
     return true;
   }
   if (!(obj instanceof CategoryAnchor)) {
     return false;
   }
   CategoryAnchor position = (CategoryAnchor) obj;
   if (!this.name.equals(position.toString())) {
     return false;
   }
   return true;
 }