public void addConstraints(Constraint... constraintsToAdd) { if (this.constraints == null) { this.constraints = new HashSet<Constraint>(constraintsToAdd.length); } for (Constraint constraint : constraintsToAdd) { getConstraints().add(constraint); constraint.setPropertyDefinitionSimple(this); } }
public void setConstraints(Set<Constraint> constraints) { // Don't replace the possible Hibernate proxy when orphanRemoval=true. It can cause // "collection with cascade=all-delete-orphan was no longer referenced" exceptions. if (constraints == null || constraints.isEmpty()) { if (null != this.constraints) { this.constraints.clear(); } return; } if (this.constraints == null) { this.constraints = new HashSet<Constraint>(constraints.size()); } for (Constraint constraint : constraints) { getConstraints().add(constraint); constraint.setPropertyDefinitionSimple(this); } }
private List<Validator> createSubValidators() { List<Validator> subValidators = new ArrayList<Validator>(); subValidators.add(new LengthValidator(PropertySimple.MAX_VALUE_LENGTH)); if (this.propertyDefinition != null) { switch (this.propertyDefinition.getType()) { case INTEGER: { subValidators.add(new LongRangeValidator(Integer.MAX_VALUE, Integer.MIN_VALUE)); break; } case LONG: { subValidators.add(new LongRangeValidator(Long.MAX_VALUE, Long.MIN_VALUE)); break; } case FLOAT: { subValidators.add(new DoubleRangeValidator(Float.MAX_VALUE, Float.MIN_VALUE)); break; } case DOUBLE: { subValidators.add(new DoubleRangeValidator(Double.MAX_VALUE, Double.MIN_VALUE)); break; // There is no need for type-based validators for booleans or enums, because the UI input controls // (e.g. radio buttons or pulldown menus) prevent invalid values from being entered. } } for (Constraint constraint : this.propertyDefinition.getConstraints()) { subValidators.add(createValidator(constraint)); } } return subValidators; }
Set<Constraint> exCon = existingPDS.getConstraints(); if (exCon.size() > 0) { for (Constraint con : exCon) { existingPDS.getConstraints().clear(); // clear out existing for (Constraint con : newPDS.getConstraints()) { existingPDS.addConstraints(con);