@Test public void testNameSpace() { Namespace ns1 = new Namespace("uri", "prefix"); Namespace ns2 = new Namespace("uri", "prefix"); Namespace ns3 = new Namespace("uri", null); Namespace ns4 = new Namespace("uri2", "prefix"); assertTrue(ns1.hasPrefix()); assertFalse(ns3.hasPrefix()); assertEquals(ns1, ns1); assertEquals(ns1, ns2); assertEquals(ns1.hashCode(), ns2.hashCode()); assertEquals(ns1.toString(), ns2.toString()); assertNotNull(ns1); assertFalse(ns1.equals(ns3)); assertFalse(ns3.equals(ns1)); assertFalse(ns1.equals(ns4)); assertFalse(ns4.equals(ns1)); assertFalse(ns1.toString().equals(ns3.toString())); assertFalse(ns1.toString().equals(ns4.toString())); }
public Namespace(String uri, String prefix) { assert uri != null; if (uri.length() == 0 && prefix.length() > 0) { throw new IllegalArgumentException("prefix cannot be not empty if the uri is empty"); } this.uri = uri; this.prefix = prefix == null ? "" : prefix; }
Namespace implements Serializable { public Namespace(String uri, String prefix) { assert uri != null; if (uri.length() == 0 && prefix.length() > 0) { throw new IllegalArgumentException("prefix cannot be not empty if the uri is empty"); } this.uri = uri; this.prefix = prefix == null ? "" : prefix; } }
Namespace implements Serializable { public Namespace(String uri, String prefix) { assert uri != null; if (uri.length() == 0 && prefix.length() > 0) { throw new IllegalArgumentException("prefix cannot be not empty if the uri is empty"); } this.uri = uri; this.prefix = prefix == null ? "" : prefix; } Namespace(String uri, String prefix); private  Namespace(); }
Namespace implements Serializable { public Namespace(String uri, String prefix) { assert uri != null; if (uri.length() == 0 && prefix.length() > 0) { throw new IllegalArgumentException("prefix cannot be not empty if the uri is empty"); } this.uri = uri; this.prefix = prefix == null ? "" : prefix; } Namespace(String uri, String prefix); private  Namespace(); boolean hasPrefix(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); }
Namespace implements Serializable { public Namespace(String uri, String prefix) { assert uri != null; if (uri.length() == 0 && prefix.length() > 0) { throw new IllegalArgumentException("prefix cannot be not empty if the uri is empty"); } this.uri = uri; this.prefix = prefix == null ? "" : prefix; } Namespace(String uri, String prefix); private  Namespace(); boolean hasPrefix(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); static final Namespace DEFAULT_NS; final String uri; final String prefix; }