/** * Executes group validation. */ private void executeGroupValidation() { try { groupedProperty.validateForPropertiesUpdate(correctUpdateMap.values()); propertyValidation = null; // NOPMD } catch (PropertyValidationException exception) { propertyValidation = exception.getPropertyValidation(); } } }
/** * Validates the update value against the property and if validation passes returns the * {@link AbstractPropertyUpdate} object. * * @param updateValue * Update value * @return {@link AbstractPropertyUpdate} * @throws PropertyValidationException * If validation fails. */ public AbstractPropertyUpdate<T> createAndValidatePropertyUpdate(T updateValue) throws PropertyValidationException { if (getValue().equals(updateValue)) { throw new PropertyValidationException("Update value for creating property update can not be same as current property value."); } PropertyValidation propertyValidation = this.validateForValue(updateValue); // if has errors raise exception, otherwise create property update if (propertyValidation.hasErrors()) { throw new PropertyValidationException(propertyValidation); } else { return this.createPropertyUpdate(updateValue); } }
/** * Validates with the group validators this property, based on the changes of the single * properties reported by update list. * * @param propertyUpdates * Information about updates. * @throws PropertyValidationException * If validation fails. */ public void validateForPropertiesUpdate(Collection<IPropertyUpdate<?>> propertyUpdates) throws PropertyValidationException { PropertyValidation propertyValidation = PropertyValidation.createFor(this); for (IGroupedProperyValidator groupedProperyValidator : validators) { groupedProperyValidator.validateForPropertyUpdates(this, propertyUpdates, propertyValidation); } // if has errors raise exception, otherwise create property update if (propertyValidation.hasErrors()) { throw new PropertyValidationException(propertyValidation); } }
/** * Sends property update event. * * @param newValue * New value. */ protected void sendPropertyUpdateEvent(V newValue) { if (!property.getValue().equals(newValue)) { try { propertyUpdate = property.createAndValidatePropertyUpdate(newValue); propertyUpdateListener.propertyUpdated(property, propertyUpdate); } catch (PropertyValidationException e) { PropertyValidation propertyValidation = e.getPropertyValidation(); propertyUpdateListener.propertyValidationFailed(property, propertyValidation); } } else { propertyUpdateListener.propertyUpdateCanceled(property); propertyUpdate = null; // NOPMD } }