use of grails.validation.Constrained in project grails-core by grails.
the class DefaultConstraintEvaluator method evaluate.
@Override
public Map<String, Constrained> evaluate(Class<?> cls, GrailsDomainClassProperty[] properties) {
Map<String, ConstrainedProperty> evaluated = resolveDelegate().evaluate(cls);
Map<String, Constrained> adapted = adaptConstraints(evaluated);
for (GrailsDomainClassProperty property : properties) {
String name = property.getName();
if (!adapted.containsKey(name)) {
adapted.remove(name);
}
}
return adapted;
}
use of grails.validation.Constrained in project grails-core by grails.
the class DomainClassPropertyComparator method compare.
public int compare(Object o1, Object o2) {
if (o1.equals(domainClass.getIdentifier())) {
return -1;
}
if (o2.equals(domainClass.getIdentifier())) {
return 1;
}
GrailsDomainClassProperty prop1 = (GrailsDomainClassProperty) o1;
GrailsDomainClassProperty prop2 = (GrailsDomainClassProperty) o2;
Constrained cp1 = (Constrained) constrainedProperties.get(prop1.getName());
Constrained cp2 = (Constrained) constrainedProperties.get(prop2.getName());
if (cp1 == null & cp2 == null) {
return prop1.getName().compareTo(prop2.getName());
}
if (cp1 == null) {
return 1;
}
if (cp2 == null) {
return -1;
}
if (cp1.getOrder() > cp2.getOrder()) {
return 1;
}
if (cp1.getOrder() < cp2.getOrder()) {
return -1;
}
return 0;
}
Aggregations