public boolean apply(AttributeDescriptor descriptor) { for (final Class<? extends Annotation> annotationClass : annotationClasses) { if (descriptor.getAnnotation(annotationClass) == null ^ !requireAll) { return !requireAll; } } return requireAll; } }
/** * Returns all fields from all {@link Bindable} types in the hierarchy of the provided * <code>clazz</code>. The collected fields gets cached. */ static Collection<Field> getFieldsFromBindableHierarchy(Class<?> clazz) { return getFieldsFromHierarchy(clazz, Bindable.class); }
/** * Load metadata of a given bindable class, merged with bindable attributes from * parent classes marked with {@link Bindable} as well. */ public static BindableMetadata forClassWithParents(final Class<?> clazz) { IBindableDescriptor descriptor = BindableDescriptorUtils.getDescriptor(clazz); final BindableMetadata bindable = new BindableMetadata(); bindable.setDescription(descriptor.getDescription()); bindable.setLabel(descriptor.getLabel()); bindable.setTitle(descriptor.getTitle()); bindable.setAttributeMetadata( asAttributeMetadata(descriptor.getAttributes())); return bindable; }
/** * A generic method for performing actions on the <code>object</code>'s hierarchy of * attributes. Allows to customize the bindable marker annotation class. For experts * only. */ static void bind(Object object, IAttributeBinderAction [] attributeBinderActions, Predicate<Field> predicate, Class<? extends Annotation> markerAnnotation) throws InstantiationException, AttributeBindingException { bind(new HashSet<Object>(), new BindingTracker(), 0, object, attributeBinderActions, predicate, markerAnnotation); }
/** * A version of {@link #set(Object, Map, boolean, Class...)} with a {@link Predicate} * instead of filtering annotations. For experts only. */ public static Map<String, Object> set(Object object, Map<String, Object> values, boolean checkRequired, Predicate<Field> predicate) throws InstantiationException, AttributeBindingException { final AttributeBinderActionBind attributeBinderActionBind = new AttributeBinderActionBind( values, checkRequired, AttributeTransformerFromString.INSTANCE, AttributeTransformerFactory.INSTANCE); final IAttributeBinderAction [] actions = new IAttributeBinderAction [] { attributeBinderActionBind, }; bind(object, actions, predicate); return attributeBinderActionBind.remainingValues; }
private Map<String, Object> getAttributes() { Map<String, Object> result = AttributeValueSet .getAttributeValues(getAttributeSets().getAttributeValueSet(attributeSetId, true)); if (result == null) { result = Maps.newHashMap(); } return result; }
public AttributeLevel getGroupingObject(BindableDescriptor bindableDescriptor, AttributeDescriptor attributeDescriptor) { if (attributeDescriptor.metadata != null) { return attributeDescriptor.metadata.getLevel(); } else { return null; } } };
public String getGroupingObject(BindableDescriptor bindableDescriptor, AttributeDescriptor attributeDescriptor) { if (attributeDescriptor.metadata != null) { return attributeDescriptor.metadata.getGroup(); } else { return null; } } };
/** * Returns attribute values from the provided {@link AttributeValueSet} or * <code>null</code> if the provided {@link AttributeValueSet} is <code>null</code>. */ public static Map<String, Object> getAttributeValues( AttributeValueSet attributeValueSet) { return attributeValueSet != null ? attributeValueSet.getAttributeValues() : null; }
static AttributeBindingException createWithNoKey(String message, Throwable cause) { return new AttributeBindingException(null, message, cause); } }
/** * Returns a flattened structure of attribute descriptors. After flattening, * {@link #attributeDescriptors} contains descriptors of all attributes and * {@link #attributeGroups} is empty. Notice that {@link BindableDescriptor}s are * immutable, so the flattened descriptor set is returned rather than flattening being * applied to the receiver. * * @return flattened descriptor */ public BindableDescriptor flatten() { return group(GroupingMethod.NONE); }
public String getTitle() { return metadata.getTitle(); }
/** * Returns the {@link AttributeValueSet} corresponding to the provided <code>id</code> * or <code>null</code> if no {@link AttributeValueSet} corresponds to the * <code>id</code>. * * @return the {@link AttributeValueSet} corresponding to the provided <code>id</code> * or <code>null</code> if no {@link AttributeValueSet} corresponds to the * <code>id</code>. */ public AttributeValueSet getAttributeValueSet(String id) { return getAttributeValueSet(id, false); }
public String getLabel() { return metadata.getLabel(); }
public String getDescription() { return metadata.getDescription(); }
/** * A generic method for performing actions on the <code>object</code>'s hierarchy of * attributes. For experts only. */ public static void bind(Object object, IAttributeBinderAction [] attributeBinderActions, Predicate<Field> predicate) throws InstantiationException, AttributeBindingException { bind(new HashSet<Object>(), new BindingTracker(), 0, object, attributeBinderActions, Predicates.<Field> and(CONSISTENCY_CHECKS, predicate), Bindable.class); }
public AttributeLevel getLevel() { return metadata.getLevel(); }
public String getGroup() { return metadata.getGroup(); }
static AttributeBindingException createWithNoKey(String message) { return new AttributeBindingException(null, message); }