private void addSubElement(Property property, ValidatableElement element) {
if ( property != null && property.isComposite() && !property.isBackRef() ) {
Component component = (Component) property.getValue();
if ( component.isEmbedded() ) return;
PropertyAccessor accessor = PropertyAccessorFactory.getPropertyAccessor( property, EntityMode.POJO );
Getter getter = accessor.getGetter( element.clazz, property.getName() );
ClassValidator validator = new ClassValidator( getter.getReturnType() );
ValidatableElement subElement = new ValidatableElement( getter.getReturnType(), validator, getter );
Iterator properties = component.getPropertyIterator();
while ( properties.hasNext() ) {
addSubElement( (Property) properties.next(), subElement );
}
if ( subElement.getSubElements().size() != 0 || subElement.validator.hasValidationRules() ) {