public final class FXBeanInfo.Builder extends Object
FXBeanInfo.newBuilder(java.lang.Object)
method) to
create a description of a JavaFX bean and represent it as
FXBeanInfo
.Modifier and Type | Method and Description |
---|---|
FXBeanInfo.Builder |
action(EventHandlerProperty p)
Generic way to register an action property.
|
FXBeanInfo.Builder |
action(String name,
EventHandler<? super ActionDataEvent> handler)
Registers action with event parameter.
|
FXBeanInfo.Builder |
action(String name,
Runnable handler)
Registers parameter-less action.
|
FXBeanInfo |
build()
Builds
FXBeanInfo from provided properties and actions. |
<T> FXBeanInfo.Builder |
constant(String name,
T value)
Registers a property with a constant value.
|
FXBeanInfo.Builder |
property(ReadOnlyProperty<?> p)
Registers a property into the builder.
|
FXBeanInfo.Builder |
property(String name,
ObservableValue<?> p)
Registers a property/value with provided name into the
builder.
|
public FXBeanInfo.Builder property(ReadOnlyProperty<?> p)
p
- the propertythis
builderpublic FXBeanInfo.Builder property(String name, ObservableValue<?> p)
name
- non-null name of the propertyp
- the observable valuethis
builderpublic <T> FXBeanInfo.Builder constant(String name, T value)
T
- type of the valuename
- non-null name of the propertyvalue
- the constant value of the propertythis
builderpublic FXBeanInfo.Builder action(String name, Runnable handler)
class CountingBean implementsFXBeanInfo
.Provider { private int count; private void addAction(ActionEvent
ev) { count += ((Number
) ev.getSource()).intValue(); } private void incrementAction() { count++; } private void addTwiceAction(ActionDataEvent
ev) { count += ev.getSource(Number
.class).intValue(); count += ev.getProperty(Number
.class, "any").intValue(); } private finalFXBeanInfo
infoWithActions =FXBeanInfo
.newBuilder(this) .action("actionWithEvent", this::addAction) .action("actionWithoutParameters", this::incrementAction) .action("actionWithData", this::addTwiceAction) .build(); @Override
publicFXBeanInfo
getFXBeanInfo() { return infoWithActions; } }
name
- name of the propertyhandler
- parameter-less handlerthis
builderpublic FXBeanInfo.Builder action(String name, EventHandler<? super ActionDataEvent> handler)
ActionEvent
or
ActionDataEvent
parameter. Following example defines
such actions:
class CountingBean implementsFXBeanInfo
.Provider { private int count; private void addAction(ActionEvent
ev) { count += ((Number
) ev.getSource()).intValue(); } private void incrementAction() { count++; } private void addTwiceAction(ActionDataEvent
ev) { count += ev.getSource(Number
.class).intValue(); count += ev.getProperty(Number
.class, "any").intValue(); } private finalFXBeanInfo
infoWithActions =FXBeanInfo
.newBuilder(this) .action("actionWithEvent", this::addAction) .action("actionWithoutParameters", this::incrementAction) .action("actionWithData", this::addTwiceAction) .build(); @Override
publicFXBeanInfo
getFXBeanInfo() { return infoWithActions; } }
name
- name of the propertyhandler
- parameter-less handlerthis
builderpublic FXBeanInfo.Builder action(EventHandlerProperty p)
EventHandlerProperty
instances. This method allows direct registration of such property. However,
rather than using this method directly, consider registering the
actions via method references:
class CountingBean implementsFXBeanInfo
.Provider { private int count; private void addAction(ActionEvent
ev) { count += ((Number
) ev.getSource()).intValue(); } private void incrementAction() { count++; } private void addTwiceAction(ActionDataEvent
ev) { count += ev.getSource(Number
.class).intValue(); count += ev.getProperty(Number
.class, "any").intValue(); } private finalFXBeanInfo
infoWithActions =FXBeanInfo
.newBuilder(this) .action("actionWithEvent", this::addAction) .action("actionWithoutParameters", this::incrementAction) .action("actionWithData", this::addTwiceAction) .build(); @Override
publicFXBeanInfo
getFXBeanInfo() { return infoWithActions; } }
In case manipulation with actual ObjectProperty
is needed, here
is an example showing a path through all the generic signatures:
class CountingBean implementsFXBeanInfo
.Provider { private int count; finalEventHandlerProperty
incrementAction = newSimpleEventHandlerProperty
(this, "actionWithoutParameters", (ev) -> { count++; }); finalEventHandlerProperty
addAction = newSimpleEventHandlerProperty
(this, "actionWithEvent", (ev) -> { count += ((Number
) ev.getSource()).intValue(); }); finalEventHandlerProperty
addTwiceAction = newSimpleEventHandlerProperty
(this, "actionWithData", (ev) -> { count += ev.getSource(Number
.class).intValue(); count += ev.getProperty(Number
.class, "any").intValue(); }); private finalFXBeanInfo
info =FXBeanInfo
.newBuilder(this) .action(this.incrementAction) .action(this.addAction) .action(this.addTwiceAction) .build(); @Override
publicFXBeanInfo
getFXBeanInfo() { return info; } }
p
- instance of EventHandlerProperty
to registerthis
builderpublic FXBeanInfo build()
FXBeanInfo
from provided properties and actions.
It clears the so far specified values.Copyright © 2020. All rights reserved.