@Test(expected = IllegalArgumentException.class) public void failsIfInvalid() throws Exception { Ern.valueOf("1234-11-44"); }
public static Ern valueOf(String value) { if (!value.matches(REGEX)) { throw new IllegalArgumentException("Invalid ERN format"); } else { String[] parts = value.split("-"); return new Ern(parts[0], parts[1], parts[2], parts[3]); } }
Ern { public static Ern valueOf(String value) { if (!value.matches(REGEX)) { throw new IllegalArgumentException("Invalid ERN format"); } else { String[] parts = value.split("-"); return new Ern(parts[0], parts[1], parts[2], parts[3]); } } }
Ern { public static Ern valueOf(String value) { if (!value.matches(REGEX)) { throw new IllegalArgumentException("Invalid ERN format"); } else { String[] parts = value.split("-"); return new Ern(parts[0], parts[1], parts[2], parts[3]); } } Ern(String wardCode, String pollingDistrict, String number, String suffix); }
Ern { public static Ern valueOf(String value) { if (!value.matches(REGEX)) { throw new IllegalArgumentException("Invalid ERN format"); } else { String[] parts = value.split("-"); return new Ern(parts[0], parts[1], parts[2], parts[3]); } } Ern(String wardCode, String pollingDistrict, String number, String suffix); static Ern valueOf(String value); String getPollingDistrict(); String getWardCode(); String getNumber(); String getSuffix(); String longForm(); String shortForm(); @Override String toString(); }
Ern { public static Ern valueOf(String value) { if (!value.matches(REGEX)) { throw new IllegalArgumentException("Invalid ERN format"); } else { String[] parts = value.split("-"); return new Ern(parts[0], parts[1], parts[2], parts[3]); } } Ern(String wardCode, String pollingDistrict, String number, String suffix); static Ern valueOf(String value); String getPollingDistrict(); String getWardCode(); String getNumber(); String getSuffix(); String longForm(); String shortForm(); @Override String toString(); static final String REGEX; }