@Override protected void addAttributesTo(Map<PropertyDescriptorField, String> attributes) { super.addAttributesTo(attributes); module.addAttributesTo(attributes); }
/** * Returns a string representation of the default value. * * @return A string representation of the default value. */ @Override protected String defaultAsString() { return asDelimitedString(defaultValue(), multiValueDelimiter()); }
private String asDelimitedString(List<V> values, char delimiter) { if (values == null) { return ""; } StringBuilder sb = new StringBuilder(); for (V value : values) { sb.append(asString(value)).append(delimiter); } if (sb.length() > 0) { sb.deleteCharAt(sb.length() - 1); } return sb.toString(); }
@Override public final String asDelimitedString(List<V> values) { return asDelimitedString(values, multiValueDelimiter()); }
@Override public List<V> valueFrom(String valueString) throws IllegalArgumentException { if (StringUtils.isBlank(valueString)) { return Collections.emptyList(); } String[] strValues = valueString.split(Pattern.quote("" + multiValueDelimiter())); List<V> values = new ArrayList<>(strValues.length); for (String strValue : strValues) { values.add(createFrom(strValue)); } return values; }
@Override public String errorFor(List<V> values) { String err; for (V value2 : values) { err = valueErrorFor(value2); if (err != null) { return err; } } return null; }
@Override public String propertyErrorFor(Rule rule) { List<V> realValues = rule.getProperty(this); return realValues == null ? null : errorFor(realValues); }
@Override protected void addAttributesTo(Map<PropertyDescriptorField, String> attributes) { super.addAttributesTo(attributes); attributes.put(PropertyDescriptorField.DELIMITER, Character.toString(multiValueDelimiter())); }
/** * Checks a single value for a "missing value" error. * * @param value Value to check * * @return A descriptive String of the error or null if there was none */ protected String valueErrorFor(V value) { return value != null || defaultHasNullValue() ? null : "missing value"; }
@Override public List<V> valueFrom(String valueString) throws IllegalArgumentException { if (StringUtils.isBlank(valueString)) { return Collections.emptyList(); } String[] strValues = valueString.split(Pattern.quote("" + multiValueDelimiter())); List<V> values = new ArrayList<>(strValues.length); for (String strValue : strValues) { values.add(createFrom(strValue)); } return values; }
@Override public final String asDelimitedString(List<V> values) { return asDelimitedString(values, multiValueDelimiter()); }
@Override protected String valueErrorFor(T value) { if (value == null) { String err = super.valueErrorFor(null); if (err != null) { return err; } } return module.valueErrorFor(value); }
@Override public String propertyErrorFor(Rule rule) { List<V> realValues = rule.getProperty(this); return realValues == null ? null : errorFor(realValues); }
@Override protected void addAttributesTo(Map<PropertyDescriptorField, String> attributes) { super.addAttributesTo(attributes); attributes.put(PropertyDescriptorField.DELIMITER, Character.toString(multiValueDelimiter())); }
/** * Checks a single value for a "missing value" error. * * @param value Value to check * * @return A descriptive String of the error or null if there was none */ protected String valueErrorFor(V value) { return value != null || defaultHasNullValue() ? null : "missing value"; }
/** * Returns a string representation of the default value. * * @return A string representation of the default value. */ @Override protected String defaultAsString() { return asDelimitedString(defaultValue(), multiValueDelimiter()); }
@Override public String errorFor(List<V> values) { String err; for (V value2 : values) { err = valueErrorFor(value2); if (err != null) { return err; } } return null; }
@Override protected void addAttributesTo(Map<PropertyDescriptorField, String> attributes) { super.addAttributesTo(attributes); module.addAttributesTo(attributes); }
private String asDelimitedString(List<V> values, char delimiter) { if (values == null) { return ""; } StringBuilder sb = new StringBuilder(); for (V value : values) { sb.append(asString(value)).append(delimiter); } if (sb.length() > 0) { sb.deleteCharAt(sb.length() - 1); } return sb.toString(); }
@Override protected String valueErrorFor(T value) { if (value == null) { String err = super.valueErrorFor(null); if (err != null) { return err; } } return module.valueErrorFor(value); }