List of usage examples for org.springframework.beans ConfigurablePropertyAccessor isWritableProperty
boolean isWritableProperty(String propertyName);
From source file:org.brushingbits.jnap.validation.constraints.AbstractConstraintValidator.java
/** * This method copies all the annotation properties to fields with the same name. * /*from w w w . j a va 2 s. c o m*/ * @param constraintAnnotation This constraint annotation. * @see PropertyAccessorFactory */ protected void bindParameters(A constraintAnnotation) { Class<?> annotationClass = constraintAnnotation.getClass(); Method[] methods = annotationClass.getDeclaredMethods(); ConfigurablePropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(this); try { for (Method method : methods) { String methodName = method.getName(); if (accessor.isWritableProperty(methodName)) { accessor.setPropertyValue(methodName, method.invoke(constraintAnnotation, ArrayUtils.EMPTY_OBJECT_ARRAY)); } } } catch (Exception e) { ReflectionUtils.handleReflectionException(e); } }
From source file:org.codehaus.groovy.grails.web.binding.GrailsDataBinder.java
private boolean isNullAndWritableProperty(ConfigurablePropertyAccessor accessor, String propertyName) { return accessor.isWritableProperty(propertyName) && (accessor.isReadableProperty(propertyName) && accessor.getPropertyValue(propertyName) == null); }