class RecipientListValidator implements ValueListValidator {

    @Override
    public void validate(List<String> values) throws XDSMetaDataException {
        noNullElements(values, "values cannot contain null elements");
//        This check is disabled for compatibility with older versions.
//        metaDataAssert(!values.isEmpty(), RECIPIENT_LIST_EMPTY);
        
        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]);
            }
        }
    }

}