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
ConstructorDescriptionBindingInfo
(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 givenFormLayout
according to this instance.protected <T> FieldComponent<T>
addNullifyCheckbox
(FieldComponent<T> fieldComponent) <V> Binder.Binding<? extends T,
?> Bind the given field to the givenBinder
according to this instance.createFieldComponent
(T bean) Instantiate a new field and associated component according to this instance.Get the (@FieldBuilder.Foo
or@FieldBuilder.ProvidesField
) annotation that annotates the method from which this instance originated.Get the associated@FieldBuilder.Binding
annotation, if any.Get the associated@FieldBuilder.EnabledBy
annotation, if any.Return theAbstractFieldBuilder
that created this instance.Get the associated@FieldBuilder.FormLayout
annotation, if any.protected String
Find a public zero-arg methodgetLabel
returningString
and invoke it, if it exists.Get the annotated method associated with this instance.Get the associated@FieldBuilder.NullifyCheckbox
annotation, if any.Get a description of the origin of this instance (method and annotation).Return the property name associated with this instance.double
Generate a sorting value for this field.protected <T> T
instantiate
(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 onmethod
binding
- associated@FieldBuilder.Binding
annotation, if anyformLayout
- associated@FieldBuilder.FormLayout
annotation, if anynullifyCheckbox
- associated@FieldBuilder.NullifyCheckbox
, if anyenabledBy
- associated from@FieldBuilder.EnabledBy
, if anyfieldBuilder
- builds the field- Throws:
IllegalArgumentException
- ifmethod
,propertyName
,annotation
, orfieldBuilder
is null
-
-
Method Details
-
getFieldBuilder
Return theAbstractFieldBuilder
that 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.Foo
annotation. 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.Foo
or@FieldBuilder.ProvidesField
) annotation that annotates the method from which this instance originated.- Returns:
- associated annotation type
-
getBinding
Get the associated@FieldBuilder.Binding
annotation, if any.- Returns:
- associated
@FieldBuilder.Binding
annotation, or null if none
-
getFormLayout
Get the associated@FieldBuilder.FormLayout
annotation, if any.- Returns:
- associated
@FieldBuilder.FormLayout
annotation, or null if none
-
getNullifyCheckbox
Get the associated@FieldBuilder.NullifyCheckbox
annotation, if any.- Returns:
- associated
@FieldBuilder.NullifyCheckbox
annotation, or null if none
-
getEnabledBy
Get the associated@FieldBuilder.EnabledBy
annotation, if any.- Returns:
- associated
@FieldBuilder.EnabledBy
annotation, 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
FieldBuilderContext
constructor 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 butbean
is null
-
addNullifyCheckbox
-
bind
Bind the given field to the givenBinder
according 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 givenFormLayout
according 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 methodgetLabel
returningString
and invoke it, if it exists.- Parameters:
obj
- target object- Returns:
- the returned label, or null on failure
-
toString
-