boolean hasNotNullFromComposingConstraints = applyConstraints( descriptor.getComposingConstraints(), property, propertyDesc, null,
boolean hasNotNull; if ( property != null ) { hasNotNull = applyConstraints( propertyDesc.getConstraintDescriptors(), property, propertyDesc, groups, activateNotNull, dialect );
private static boolean applyConstraints(Set<ConstraintDescriptor<?>> constraintDescriptors, Property property, PropertyDescriptor propertyDesc, Set<Class<?>> groups, boolean canApplyNotNull) { boolean hasNotNull = false; for (ConstraintDescriptor<?> descriptor : constraintDescriptors) { if ( groups != null && Collections.disjoint( descriptor.getGroups(), groups) ) continue; if ( canApplyNotNull ) { hasNotNull = hasNotNull || applyNotNull( property, descriptor ); } // apply bean validation specific constraints applyDigits( property, descriptor ); applySize( property, descriptor, propertyDesc ); applyMin( property, descriptor ); applyMax( property, descriptor ); // apply hibernate validator specific constraints - we cannot import any HV specific classes though! applyLength( property, descriptor, propertyDesc ); // pass an empty set as composing constraints inherit the main constraint and thus are matching already hasNotNull = hasNotNull || applyConstraints( descriptor.getComposingConstraints(), property, propertyDesc, null, canApplyNotNull ); } return hasNotNull; }
private static void applyDDL(String prefix, PersistentClass persistentClass, Class<?> clazz, ValidatorFactory factory, Set<Class<?>> groups, boolean activateNotNull) { final BeanDescriptor descriptor = factory.getValidator().getConstraintsForClass( clazz ); //no bean level constraints can be applied, go to the properties for ( PropertyDescriptor propertyDesc : descriptor.getConstrainedProperties() ) { Property property = findPropertyByName( persistentClass, prefix + propertyDesc.getPropertyName() ); boolean hasNotNull = false; if ( property != null ) { hasNotNull = applyConstraints( propertyDesc.getConstraintDescriptors(), property, propertyDesc, groups, activateNotNull ); if ( property.isComposite() && propertyDesc.isCascaded() ) { Class<?> componentClass = ( ( Component ) property.getValue() ).getComponentClass(); /* * we can apply not null if the upper component let's us activate not null * and if the property is not null. * Otherwise, all sub columns should be left nullable */ final boolean canSetNotNullOnColumns = activateNotNull && hasNotNull; applyDDL( prefix + propertyDesc.getPropertyName() + ".", persistentClass, componentClass, factory, groups, canSetNotNullOnColumns ); } //FIXME add collection of components } } }
hasNotNull = hasNotNull || applyConstraints( descriptor.getComposingConstraints(), property, propertyDesc, null,
hasNotNull = hasNotNull || applyConstraints( descriptor.getComposingConstraints(), property, propertyDesc, null,
boolean hasNotNullFromComposingConstraints = applyConstraints( descriptor.getComposingConstraints(), property, propertyDesc, null,
boolean hasNotNull; if ( property != null ) { hasNotNull = applyConstraints( propertyDesc.getConstraintDescriptors(), property, propertyDesc, groups, activateNotNull, dialect );
boolean hasNotNull; if ( property != null ) { hasNotNull = applyConstraints( propertyDesc.getConstraintDescriptors(), property, propertyDesc, groups, activateNotNull, dialect );
boolean hasNotNull; if ( property != null ) { hasNotNull = applyConstraints( propertyDesc.getConstraintDescriptors(), property, propertyDesc, groups, activateNotNull, dialect );