/** * {@inheritDoc} */ @Override protected String getErrorMessage(SingleProperty<? extends T> property) { return "Value of property '" + property.getName() + "' must not be empty String/Collection/Map"; } }
/** * Gets {@link #value}. * * @return {@link #value} */ public T getValue() { if (null != getUsedValue()) { return getUsedValue(); } else { return getDefaultValue(); } }
/** * Sets this property to use default value. */ public void setToDefaultValue() { setUsedValue(null); }
/** * {@inheritDoc} */ public void validate(SingleProperty<? extends T> property, PropertyValidation propertyValidation) { if (!prove(property.getValue())) { addValidationError(property, propertyValidation, getErrorMessage(property)); } }
@BeforeMethod public void init() { MockitoAnnotations.initMocks(this); configuration = new Configuration(); PropertySection section = new PropertySection(); section.addProperty(property1); section.addProperty(property2); configuration.addSection(section); }
/** * Returns property value as human-readable string . * * @return Returns property value as human-readable string . */ public String getFormattedValue() { return getValue().toString(); }
/** * Default constructor. * * @param groupedProperty * {@link GroupedProperty} to display. * @see PropertyPreferencePage#PropertyPreferencePage(String, java.util.Collection) */ public GroupedPropertyPreferencePage(GroupedProperty groupedProperty) { super(groupedProperty.getName(), groupedProperty.getSingleProperties()); this.setDescription(groupedProperty.getDescription()); this.groupedProperty = groupedProperty; }
/** * Returns the {@link SingleProperty} with the given logical name in the configuration or * <code>null</code> if such does not exist. * * @param <T> * Type of property value. * * @param propertyLogicalName * Property logical name to search for. * @return {@link SingleProperty} or <code>null</code> */ @SuppressWarnings("unchecked") public <T> SingleProperty<T> forLogicalName(String propertyLogicalName) { for (AbstractProperty property : getAllProperties()) { SingleProperty<?> returnProperty = property.forLogicalname(propertyLogicalName); if (null != returnProperty) { return (SingleProperty<T>) returnProperty; } } return null; }
/** * Validate current property value(s) and report any validation problems via the * {@link PropertyValidation} that is returned. * * @return {@link PropertyValidation} containing validation errors if found. */ public PropertyValidation validate() { PropertyValidation errors = PropertyValidation.createFor(this); validate(errors); return errors; }
/** * {@inheritDoc} */ @Override public void register(Properties properties) { if (CollectionUtils.isNotEmpty(singleProperties)) { for (SingleProperty<?> property : singleProperties) { property.register(properties); } } }
/** * Returns the currently existing {@link PropertySection} in the CMR configuration. * * @return Returns the currently existing {@link PropertySection} in the CMR configuration. */ public Collection<PropertySection> getConfigurationPropertySections() { return configuration.getSections(); }
/** * {@inheritDoc} */ @Override public SingleProperty<?> forLogicalname(String propertyLogicalName) { for (AbstractProperty property : singleProperties) { SingleProperty<?> returnProperty = property.forLogicalname(propertyLogicalName); if (null != returnProperty) { return returnProperty; } } return null; }
/** * {@inheritDoc} */ @Override protected String getErrorMessage(SingleProperty<? extends T> property) { return "Value of property '" + property.getName() + "' must be a percentage value"; } }
/** * If default value is used for this property. * * @return If default value is used for this property. */ public boolean isDefaultValueUsed() { if (null != getUsedValue()) { return getUsedValue().equals(getDefaultValue()); } else { return true; } }
/** * Sets {@link #value}. * * @param value * New value for {@link #value} */ public void setValue(T value) { setUsedValue(value); }
/** * {@inheritDoc} */ @Override protected String getErrorMessage(SingleProperty<? extends String> property) { return "Value of property '" + property.getName() + "' is not a valid e-mail address"; } }
/** * {@inheritDoc} */ @Override protected String getErrorMessage(SingleProperty<? extends String> property) { return "At least one entry in property '" + property.getName() + "' is not a valid e-mail address"; }
/** * {@inheritDoc} */ @Override protected String getErrorMessage(SingleProperty<? extends String> property) { return "Value of property '" + property.getName() + "' must be a fully qualified class name"; } }
/** * {@inheritDoc} */ @Override protected String getErrorMessage(SingleProperty<? extends T> property) { return "Value of property '" + property.getName() + "' must be negative"; } }
/** * {@inheritDoc} */ @Override protected String getErrorMessage(SingleProperty<? extends T> property) { return "Value of property '" + property.getName() + "' must be positive"; } }