GeneratedEnumType implements Type { @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Type)) { return false; } if (o instanceof GeneratedEnumType) { final GeneratedEnumType that = (GeneratedEnumType) o; return typeName.equals(that.typeName) && constants.equals(that.constants); } else { return typeName.equals(((Type) o).getTypeName()); } } GeneratedEnumType(String typeName, List<String> constants); List<String> getEnumConstants(); @Override String getTypeName(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test void testEquals() { final List<String> otherConstants = new ArrayList<>(ENUM_CONSTANTS); otherConstants.add("Z"); final GeneratedEnumType other = new GeneratedEnumType(TYPE_NAME, otherConstants); assertEquals(instance, instance); assertFalse(instance.equals(null)); assertFalse(instance.equals(1)); assertFalse(instance.equals(Integer.class)); assertNotEquals(instance, other); assertNotEquals(other, instance); }