Property property = findPropertyByName( persistentClass, prefix + propertyDesc.getPropertyName() ); boolean hasNotNull; if ( property != null ) { prefix + propertyDesc.getPropertyName() + ".", persistentClass, componentClass, factory, groups, canSetNotNullOnColumns,
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 } } }
private String validateMethodFieldName(PropertyDescriptor p) { return "validateProperty_" + p.getPropertyName(); }
private String validateMethodGetterName(PropertyDescriptor p) { return "validateProperty_get" + p.getPropertyName(); }
private String validateMethodGetterName(PropertyDescriptor p) { return "validateProperty_get" + p.getPropertyName(); }
@Override public boolean apply(PropertyDescriptor input) { return input.getPropertyName().equals(p.getPropertyName()); } };
@Override public boolean apply(PropertyDescriptor input) { return input.getPropertyName().equals(p.getPropertyName()); } };
private Predicate<PropertyDescriptor> newPropertyNameMatches( final PropertyDescriptor ppropertyDescription) { return input -> input.getPropertyName().equals(ppropertyDescription.getPropertyName()); }
@Override public PropertyDescriptor getConstraintsForProperty(final String propertyName) { for (final PropertyDescriptor propertyDescriptor : constrainedProperties) { if (propertyDescriptor.getPropertyName().equals(propertyName)) { return propertyDescriptor; } } return null; }
boolean hasField(PropertyDescriptor p) { JField field = jClass.findField(p.getPropertyName()); return field != null; }
boolean hasField(PropertyDescriptor p) { JField field = jClass.findField(p.getPropertyName()); return field != null; }
public void push(final PropertyDescriptor property) { pathNodes.add(new MinijaxPropertyNode(pathNodes.size(), property.getPropertyName())); }
public static String asGetter(PropertyDescriptor p) { return "get" + capitalizeFirstLetter(p.getPropertyName()); }
public static String asGetter(PropertyDescriptor p) { return "get" + capitalizeFirstLetter(p.getPropertyName()); }
boolean hasField(final PropertyDescriptor ppropertyDescriptor) { final JField field = jclass.findField(ppropertyDescriptor.getPropertyName()); return field != null; }
@Test @SpecAssertion(section = Sections.CONSTRAINTMETADATA_PROPERTYDESCRIPTOR, id = "a") public void testPropertyName() { String propertyName = "orderList"; PropertyDescriptor descriptor = getPropertyDescriptor( Customer.class, propertyName ); assertEquals( descriptor.getPropertyName(), propertyName, "Wrong property name" ); }
@Test @SpecAssertion(section = "5.4", id = "b") public void testPropertyName() { String propertyName = "orderList"; PropertyDescriptor descriptor = getPropertyDescriptor( Customer.class, propertyName ); assertEquals( descriptor.getPropertyName(), propertyName, "Wrong property name" ); } }
@Test @SpecAssertion(section = Sections.CONSTRAINTMETADATA_VALIDATOR, id = "a") @SpecAssertion(section = Sections.CONSTRAINTMETADATA_BEANDESCRIPTOR, id = "d") public void testGetConstrainedProperties() { BeanDescriptor beanDescriptor = getValidator().getConstraintsForClass( Order.class ); Set<PropertyDescriptor> constraintProperties = beanDescriptor.getConstrainedProperties(); assertEquals( constraintProperties.size(), 1, "There should be only one property" ); boolean hasOrderNumber = false; for ( PropertyDescriptor pd : constraintProperties ) { hasOrderNumber |= pd.getPropertyName().equals( "orderNumber" ); } assertTrue( hasOrderNumber, "Wrong property" ); }
JType getElementType(PropertyDescriptor p, boolean useField) { if (useField) { return jClass.findField(p.getPropertyName()).getType(); } else { return jClass.findMethod(GwtSpecificValidatorCreator.asGetter(p), GwtSpecificValidatorCreator.NO_ARGS).getReturnType(); } }
JType getElementType(PropertyDescriptor p, boolean useField) { if (useField) { return jClass.findField(p.getPropertyName()).getType(); } else { return jClass.findMethod(GwtSpecificValidatorCreator.asGetter(p), GwtSpecificValidatorCreator.NO_ARGS).getReturnType(); } }