Identifier implements Serializable { public static Identifier ip(InetAddress ip) { return new Identifier(TYPE_IP, ip.getHostAddress()); } 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 testIp() throws UnknownHostException { Identifier id1 = Identifier.ip(InetAddress.getByName("192.168.1.2")); assertThat(id1.getType(), is(Identifier.TYPE_IP)); assertThat(id1.getValue(), is("192.168.1.2")); assertThat(id1.getIP().getHostAddress(), is("192.168.1.2")); Identifier id2 = Identifier.ip(InetAddress.getByName("2001:db8:85a3::8a2e:370:7334")); assertThat(id2.getType(), is(Identifier.TYPE_IP)); assertThat(id2.getValue(), is("2001:db8:85a3:0:0:8a2e:370:7334")); assertThat(id2.getIP().getHostAddress(), is("2001:db8:85a3:0:0:8a2e:370:7334")); Identifier id3 = Identifier.ip("192.168.2.99"); assertThat(id3.getType(), is(Identifier.TYPE_IP)); assertThat(id3.getValue(), is("192.168.2.99")); assertThat(id3.getIP().getHostAddress(), is("192.168.2.99")); }