Class AbstractFieldBuilder.BindingInfo
java.lang.Object
org.dellroad.stuff.vaadin24.field.AbstractFieldBuilder.BindingInfo
- Enclosing class:
- AbstractFieldBuilder<S extends AbstractFieldBuilder<S,
T>, T>
FieldBuilder static configuration information for one bean property.
This class captures the information gathered from these annotations for some bean property:
@FieldBuilder.Foo(for some widget classFoo)@FieldBuilder.ProvidesField@FieldBuilder.Binding@FieldBuilder.FormLayout@FieldBuilder.NullifyCheckbox@FieldBuilder.EnabledBy
Instances are immutable.
-
Constructor Summary
ConstructorsConstructorDescriptionBindingInfo(Method method, String propertyName, Annotation annotation, AbstractFieldBuilder.Binding binding, AbstractFieldBuilder.FormLayout formLayout, AbstractFieldBuilder.NullifyCheckbox nullifyCheckbox, AbstractFieldBuilder.EnabledBy enabledBy, BiFunction<AbstractFieldBuilder<S, T>.BindingInfo, ? super T, FieldComponent<?>> fieldBuilder) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionaddField(FormLayout formLayout, Component component) Add the given component to the givenFormLayoutaccording to this instance.protected <T> FieldComponent<T>addNullifyCheckbox(FieldComponent<T> fieldComponent) <V> Binder.Binding<? extends T,?> Bind the given field to the givenBinderaccording to this instance.createFieldComponent(T bean) Instantiate a new field and associated component according to this instance.Get the (@FieldBuilder.Fooor@FieldBuilder.ProvidesField) annotation that annotates the method from which this instance originated.Get the associated@FieldBuilder.Bindingannotation, if any.Get the associated@FieldBuilder.EnabledByannotation, if any.Return theAbstractFieldBuilderthat created this instance.Get the associated@FieldBuilder.FormLayoutannotation, if any.protected StringFind a public zero-arg methodgetLabelreturningStringand invoke it, if it exists.Get the annotated method associated with this instance.Get the associated@FieldBuilder.NullifyCheckboxannotation, if any.Get a description of the origin of this instance (method and annotation).Return the property name associated with this instance.doubleGenerate a sorting value for this field.protected <T> Tinstantiate(Class<T> type) Instantiate a field (or whatever) from the givenClass.toString()
-
Constructor Details
-
BindingInfo
public BindingInfo(Method method, String propertyName, Annotation annotation, AbstractFieldBuilder.Binding binding, AbstractFieldBuilder.FormLayout formLayout, AbstractFieldBuilder.NullifyCheckbox nullifyCheckbox, AbstractFieldBuilder.EnabledBy enabledBy, BiFunction<AbstractFieldBuilder<S, T>.BindingInfo, ? super T, FieldComponent<?>> fieldBuilder) Constructor.- Parameters:
method- annotated methodpropertyName- property nameannotation- annotation found onmethodbinding- associated@FieldBuilder.Bindingannotation, if anyformLayout- associated@FieldBuilder.FormLayoutannotation, if anynullifyCheckbox- associated@FieldBuilder.NullifyCheckbox, if anyenabledBy- associated from@FieldBuilder.EnabledBy, if anyfieldBuilder- builds the field- Throws:
IllegalArgumentException- ifmethod,propertyName,annotation, orfieldBuilderis null
-
-
Method Details
-
getFieldBuilder
Return theAbstractFieldBuilderthat created this instance.- Returns:
- associated field builder
-
getMethod
Get the annotated method associated with this instance.This is the method that is annotated with the
@FieldBuilder.Fooannotation. Note that the other annotations (e.g.,@FieldBuilder.Binding) could possibly have come from different methods (they would necessarily be overriding or overridden versions of this method).- Returns:
- associated method
-
getPropertyName
Return the property name associated with this instance.- Returns:
- associated property name
-
getAnnotation
Get the (@FieldBuilder.Fooor@FieldBuilder.ProvidesField) annotation that annotates the method from which this instance originated.- Returns:
- associated annotation type
-
getBinding
Get the associated@FieldBuilder.Bindingannotation, if any.- Returns:
- associated
@FieldBuilder.Bindingannotation, or null if none
-
getFormLayout
Get the associated@FieldBuilder.FormLayoutannotation, if any.- Returns:
- associated
@FieldBuilder.FormLayoutannotation, or null if none
-
getNullifyCheckbox
Get the associated@FieldBuilder.NullifyCheckboxannotation, if any.- Returns:
- associated
@FieldBuilder.NullifyCheckboxannotation, or null if none
-
getEnabledBy
Get the associated@FieldBuilder.EnabledByannotation, if any.- Returns:
- associated
@FieldBuilder.EnabledByannotation, or null if none
-
getSortOrder
public double getSortOrder()Generate a sorting value for this field.- Returns:
- sort order value
-
getOrigin
Get a description of the origin of this instance (method and annotation).- Returns:
- origin description
-
instantiate
Instantiate a field (or whatever) from the givenClass.We use the
FieldBuilderContextconstructor if available, otherwise default constructor.- Parameters:
type- expected type of thing we're instantiating
-
createFieldComponent
Instantiate a new field and associated component according to this instance.- Parameters:
bean- instance bean, or null if none available- Returns:
- new field and associated component
- Throws:
IllegalArgumentException- if a bean instance is required butbeanis null
-
addNullifyCheckbox
-
bind
Bind the given field to the givenBinderaccording to this instance.- Type Parameters:
V- field value type- Parameters:
binder- binder to bind new field tofield- field to bind- Returns:
- the new binding
- Throws:
IllegalArgumentException- if either parameter is null
-
addField
Add the given component to the givenFormLayoutaccording to this instance.- Parameters:
formLayout- target layoutcomponent- field component to add- Returns:
- the added
FormLayout.FormItem - Throws:
IllegalArgumentException- if either parameter is null
-
getLabel
Find a public zero-arg methodgetLabelreturningStringand invoke it, if it exists.- Parameters:
obj- target object- Returns:
- the returned label, or null on failure
-
toString
-