/** * Utility to check if the strings in a array of strings match acceptable values. If the input array is null then * nothing is done. * * @param isNullable if the value is allowed to be null or not. * @param validationContext The context of the item in the class being validated. This is used in case of an error. * @param values a array of strings to validate. * @param acceptableValues list acceptable values for the input array. * @return returns an error if string is not present in list. Otherwise returns an empty list. */ protected static List<RaveError> checkStringDef( boolean isNullable, ValidationContext validationContext, @Nullable String[] values, String... acceptableValues) { List<RaveError> errors = checkNullable(values, isNullable, validationContext); if (values == null) { return errors; } for (String s : values) { errors = mergeErrors(errors, checkStringDef(false, validationContext, s, acceptableValues)); } return errors == null ? Collections.<RaveError>emptyList() : errors; }
/** * Utility to check if the strings in a {@link Collection} of strings match acceptable values. If the input * {@link Collection} is null then nothing is done. * * @param isNullable if the value is allowed to be null or not. * @param validationContext The context of the item in the class being validated. This is used in case of an error. * @param values a {@link Collection} of strings to validate. * @param acceptableValues list acceptable values for the input list. * @return returns an error if string is not present in list. Otherwise returns an empty list. */ protected static List<RaveError> checkStringDef( boolean isNullable, ValidationContext validationContext, @Nullable Collection<String> values, String... acceptableValues) { List<RaveError> errors = checkNullable(values, isNullable, validationContext); if (values == null) { return errors; } for (String s : values) { errors = mergeErrors(errors, checkStringDef(false, validationContext, s, acceptableValues)); } return errors == null ? Collections.<RaveError>emptyList() : errors; }