@Override public <T> void setProperty(PropertyDescriptor<T> propertyDescriptor, T value) { checkValidPropertyDescriptor(propertyDescriptor); if (value instanceof List) { propertyValuesByDescriptor.put(propertyDescriptor, Collections.unmodifiableList((List) value)); } else { propertyValuesByDescriptor.put(propertyDescriptor, value); } }
@Override public String dysfunctionReason() { for (PropertyDescriptor<?> descriptor : getOverriddenPropertyDescriptors()) { String error = errorForPropCapture(descriptor); if (error != null) { return error; } } return null; }
@Override public void definePropertyDescriptor(PropertyDescriptor<?> propertyDescriptor) { // Check to ensure the property does not already exist. if (getPropertyDescriptor(propertyDescriptor.name()) != null) { throw new IllegalArgumentException("There is already a PropertyDescriptor with name '" + propertyDescriptor.name() + "' defined on " + getPropertySourceType() + " " + getName() + "."); } propertyDescriptors.add(propertyDescriptor); // Sort in UI order Collections.sort(propertyDescriptors); }
/** * Checks whether this property descriptor is defined for this property source. * * @param propertyDescriptor The property descriptor to check */ private void checkValidPropertyDescriptor(PropertyDescriptor<?> propertyDescriptor) { if (!hasDescriptor(propertyDescriptor)) { throw new IllegalArgumentException("Property descriptor not defined for " + getPropertySourceType() + " " + getName() + ": " + propertyDescriptor); } }
private <T> String errorForPropCapture(PropertyDescriptor<T> descriptor) { return descriptor.errorFor(getProperty(descriptor)); } }
@Override @Deprecated public boolean usesDefaultValues() { Map<PropertyDescriptor<?>, Object> valuesByProperty = getPropertiesByPropertyDescriptor(); if (valuesByProperty.isEmpty()) { return true; } for (Entry<PropertyDescriptor<?>, Object> entry : valuesByProperty.entrySet()) { if (!CollectionUtil.areEqual(entry.getKey().defaultValue(), entry.getValue())) { return false; } } return true; }
/** * Checks whether this property descriptor is defined for this property source. * * @param propertyDescriptor The property descriptor to check */ private void checkValidPropertyDescriptor(PropertyDescriptor<?> propertyDescriptor) { if (!hasDescriptor(propertyDescriptor)) { throw new IllegalArgumentException("Property descriptor not defined for " + getPropertySourceType() + " " + getName() + ": " + propertyDescriptor); } }
private <T> String errorForPropCapture(PropertyDescriptor<T> descriptor) { return descriptor.errorFor(getProperty(descriptor)); } }
@Override @Deprecated public boolean usesDefaultValues() { Map<PropertyDescriptor<?>, Object> valuesByProperty = getPropertiesByPropertyDescriptor(); if (valuesByProperty.isEmpty()) { return true; } for (Entry<PropertyDescriptor<?>, Object> entry : valuesByProperty.entrySet()) { if (!CollectionUtil.areEqual(entry.getKey().defaultValue(), entry.getValue())) { return false; } } return true; }
@Override public void definePropertyDescriptor(PropertyDescriptor<?> propertyDescriptor) { // Check to ensure the property does not already exist. if (getPropertyDescriptor(propertyDescriptor.name()) != null) { throw new IllegalArgumentException("There is already a PropertyDescriptor with name '" + propertyDescriptor.name() + "' defined on " + getPropertySourceType() + " " + getName() + "."); } propertyDescriptors.add(propertyDescriptor); // Sort in UI order Collections.sort(propertyDescriptors); }
@Override public String dysfunctionReason() { for (PropertyDescriptor<?> descriptor : getOverriddenPropertyDescriptors()) { String error = errorForPropCapture(descriptor); if (error != null) { return error; } } return null; }
@Override @Deprecated public <V> void setProperty(MultiValuePropertyDescriptor<V> propertyDescriptor, V... values) { checkValidPropertyDescriptor(propertyDescriptor); propertyValuesByDescriptor.put(propertyDescriptor, Collections.unmodifiableList(Arrays.asList(values))); }
@Override public <T> T getProperty(PropertyDescriptor<T> propertyDescriptor) { checkValidPropertyDescriptor(propertyDescriptor); T result = propertyDescriptor.defaultValue(); if (propertyValuesByDescriptor.containsKey(propertyDescriptor)) { @SuppressWarnings("unchecked") T value = (T) propertyValuesByDescriptor.get(propertyDescriptor); result = value; } return result; }
@Override public <T> void setProperty(PropertyDescriptor<T> propertyDescriptor, T value) { checkValidPropertyDescriptor(propertyDescriptor); if (value instanceof List) { propertyValuesByDescriptor.put(propertyDescriptor, Collections.unmodifiableList((List) value)); } else { propertyValuesByDescriptor.put(propertyDescriptor, value); } }
@Override @Deprecated public <V> void setProperty(MultiValuePropertyDescriptor<V> propertyDescriptor, V... values) { checkValidPropertyDescriptor(propertyDescriptor); propertyValuesByDescriptor.put(propertyDescriptor, Collections.unmodifiableList(Arrays.asList(values))); }
@Override public <T> T getProperty(PropertyDescriptor<T> propertyDescriptor) { checkValidPropertyDescriptor(propertyDescriptor); T result = propertyDescriptor.defaultValue(); if (propertyValuesByDescriptor.containsKey(propertyDescriptor)) { @SuppressWarnings("unchecked") T value = (T) propertyValuesByDescriptor.get(propertyDescriptor); result = value; } return result; }