@Retention(CLASS) @Target({FIELD})
public @interface Bind
Pairs a @Bindable field with the component it should mirror.
name is the value the target component returns from
Component#getName(). attr picks the attribute to write: text, UIID,
selected state, visible / hidden, the icon name, or the component name
itself.
One-way bindings push from the model to the component on
Binders.bind. Two-way bindings additionally listen for user input on
text fields, text areas, and check boxes so changes flow back into the
model.
Accessor resolution
The annotation processor decides how to read and write the field in this order:
- Explicit accessor names –
@Bind(getter="getX", setter="setX"). Use this when the JavaBeans naming convention doesn’t match (a fluent setter, a renamed boolean, …). - JavaBeans accessors when both
getterandsetterare blank:getFoo()/isFoo()for the getter,setFoo(T)for the setter. Detected from the project’s compiled bytecode – no runtime reflection. - Direct public-field access as a last resort. The processor fails the build with a clear error when the field is private and no usable accessor exists.
For two-way bindings the build-time processor instruments the resolved
setter to call Binders.notifyChanged(this) at every return point.
Application code can mutate the model through the setter from anywhere
and the bound component refreshes automatically; see
Annotation-Component-Binding.asciidoc for the loop-guard details.
Methods
public abstract String name() | Component#getName() of the target component. |
public abstract BindAttr attr() default BindAttr.TEXT | Which property of the component the field mirrors. |
public abstract boolean twoWay() default true | When false the binding is one-way (model -> component only). |
public abstract String getter() default "" | Explicit getter method name. |
public abstract String setter() default "" | Explicit setter method name. |
Method details
name
public abstract String name()Component#getName() of the target component.attr
public abstract BindAttr attr() default BindAttr.TEXTTEXT.twoWay
public abstract boolean twoWay() default truetrue for TEXT against editable components and for
SELECTED; for all other attributes the binding is implicitly
one-way regardless of this flag.getter
public abstract String getter() default ""get<Field> / is<Field> discovery, then falls back to
direct public-field access.setter
public abstract String setter() default ""set<Field> discovery, then falls back to direct
public-field assignment. The resolved setter (whether explicit or
detected) is instrumented for two-way bindings.