/** * Checks whether a given parameter value applies to this filter. * * @param parameterValue the value to check if applies to this parameter filter * @return {@code true} if {@code parameterValue} is valid according to this filter, {@code * false} otherwise */ @Override public boolean applies(@Nullable String parameterValue) { return getLegalValues().contains(getNormalize().apply(parameterValue)); }
@Override public String apply(@Nullable String str) throws ParameterException { if (str == null || str.length() == 0) { return getDefaultValue(); } str = getNormalize().apply(str); if (getLegalValues().contains(str)) { return str; } throw new ParameterException(str + " violates filter for parameter " + getKey()); }
@Override public String apply(String str) throws ParameterException { if (str == null || str.length() == 0) { return getDefaultValue(); } if (getMatcher(str).matches()) { return getNormalize().apply(str); } throw new ParameterException(str + " violates filter for parameter " + getKey()); }