Identifier implements java.io.Serializable { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Identifier)) { return false; } Identifier rhs = (Identifier) obj; if ((NullChecker.isNullish(this.getId())) || (this.getOrganizationId() == null) || (NullChecker.isNullish(rhs.getId())) || (rhs.getOrganizationId() == null)) { return false; } return this.getId().contentEquals(rhs.getId()) && this.getOrganizationId().contentEquals(rhs.getOrganizationId()); } Identifier();  Identifier(String id, String organizationId); String getOrganizationId(); void setOrganizationId(String identifier); String getId(); void setId(String id); @Override boolean equals(Object obj); @Override int hashCode();  }
@Test public void testEquals() { Identifier ident1 = new Identifier("123", "abc"); assertTrue(ident1.equals(ident1)); assertTrue(ident1.hashCode() == ident1.hashCode()); Identifier ident2 = new Identifier("123", "abc"); assertTrue(ident1.equals(ident2)); assertTrue(ident1.hashCode() == ident2.hashCode()); Identifier ident3 = new Identifier("456", "abc"); assertFalse(ident1.equals(ident3)); assertTrue(ident1.hashCode() != ident3.hashCode()); Identifier ident4 = new Identifier("123", "def"); assertFalse(ident1.equals(ident4)); assertTrue(ident1.hashCode() != ident4.hashCode()); String test = new String(); assertFalse(ident1.equals(test)); Identifier ident5 = new Identifier("123", null); Identifier ident6 = new Identifier("123", null); assertFalse(ident5.equals(ident6)); assertFalse(ident5.hashCode() != ident6.hashCode()); }