/** * Builds {@link AttributeDescriptor} for a field from a {@link Bindable} type. */ private static AttributeDescriptor buildAttributeDescriptor( Object initializedInstance, Field field, BindableMetadata bindableMetadata) { Object defaultValue = null; try { defaultValue = field.get(initializedInstance); } catch (IllegalAccessException e) { throw new AssertionError("An attribute field must be public: " + field.getDeclaringClass().getName() + "#" + field.getName()); } catch (Exception e) { throw new RuntimeException("Could not retrieve default value of attribute: " + BindableUtils.getKey(field), e); } AttributeMetadata attributeMetadata = null; if (bindableMetadata != null) { attributeMetadata = bindableMetadata.getAttributeMetadata().get( field.getName()); } return new AttributeDescriptor(field, defaultValue, getConstraintAnnotations(field), attributeMetadata); }