Identifier implements Serializable { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof Identifier)) { return false; } Identifier i = (Identifier) obj; return type.equals(i.type) && value.equals(i.value); } Identifier(String type, String value);  Identifier(JSON json); static Identifier dns(String domain); static Identifier ip(InetAddress ip); static Identifier ip(String ip); String getType(); String getValue(); String getDomain(); InetAddress getIP(); Map<String, Object> toMap(); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode(); static final String TYPE_DNS; static final String TYPE_IP; }
@Test public void testEquals() { Identifier idRef = new Identifier("foo", "123.456"); Identifier id1 = new Identifier("foo", "123.456"); assertThat(idRef.equals(id1), is(true)); Identifier id2 = new Identifier("bar", "654.321"); assertThat(idRef.equals(id2), is(false)); Identifier id3 = new Identifier("foo", "555.666"); assertThat(idRef.equals(id3), is(false)); Identifier id4 = new Identifier("sna", "123.456"); assertThat(idRef.equals(id4), is(false)); assertThat(idRef.equals(new Object()), is(false)); assertThat(idRef.equals(null), is(false)); }