AgencyAndId implements Serializable, Comparable<AgencyAndId> { public static AgencyAndId convertFromString(String value, char separator) { int index = value.indexOf(separator); if (index == -1) { throw new IllegalStateException("invalid agency-and-id: " + value); } else { return new AgencyAndId(value.substring(0, index), value.substring(index + 1)); } } AgencyAndId();  AgencyAndId(String agencyId, String id); String getAgencyId(); void setAgencyId(String agencyId); String getId(); void setId(String id); boolean hasValues(); int compareTo(AgencyAndId o); static AgencyAndId convertFromString(String value, char separator); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static AgencyAndId convertFromString(String value); static String convertToString(AgencyAndId aid); static final char ID_SEPARATOR; }
@Test public void testConvertFromString() { AgencyAndId id = AgencyAndId.convertFromString("a_b"); assertEquals("a",id.getAgencyId()); assertEquals("b",id.getId()); id = AgencyAndId.convertFromString("a_b_c"); assertEquals("a",id.getAgencyId()); assertEquals("b_c",id.getId()); try { AgencyAndId.convertFromString("ab"); fail(); } catch (IllegalArgumentException ex) { } }