RecipientListValidator implements ValueListValidator { @Override public void validate(List<String> values) throws XDSMetaDataException { noNullElements(values, "values cannot contain null elements"); for (String value : values) { metaDataAssert(!value.isEmpty(), RECIPIENT_EMPTY); String[] parts = value.split("\\|", 4); metaDataAssert((parts.length > 0) && (parts.length <= 3), INVALID_RECIPIENT, value); if (! parts[0].isEmpty()) { xonValidator.validate(parts[0]); } if ((parts.length > 1) && (! parts[1].isEmpty())) { xcnValidator.validate(parts[1]); } } }  @Override void validate(List<String> values);  }
@Test public void testValidateGoodCases() throws XDSMetaDataException { validator.validate(Arrays.asList("Some Hospital|^Welby")); validator.validate(Arrays.asList("|^Welby")); validator.validate(Arrays.asList("|ONLYID")); validator.validate(Arrays.asList("Some Hospital")); validator.validate(Arrays.asList("Some Hospital", "|^Welby")); }