Class TextFormatterBuilder<V>
java.lang.Object
io.github.sosuisen.jfxbuilder.controls.TextFormatterBuilder<V>
The
TextFormatterBuilder
class constructs instances of the TextFormatter
class
and offers a fluent interface for creating and configuring it.
This class includes a static create
method that accepts the same arguments as the original TextFormatter
constructor
and returns an instance of the TextFormatterBuilder
.
You can use method chaining to call the builder methods for configuring the TextFormatter
.
Finally, invoke the build
method to generate an instance of the TextFormatter
class.
Note that intermediate builder methods are not evaluated until the build
method
is called, meaning they are evaluated lazily.
- Author:
- Hidekazu Kubota <hidekazu.kubota@gmail.com>
-
Method Summary
Modifier and TypeMethodDescriptionapply
(Consumer<TextFormatter<V>> func) Applies a function to the TextFormatter instance being constructed.build()
Builds and returns an instance of theTextFormatter
class.static <V> TextFormatterBuilder
<V> create
(UnaryOperator<TextFormatter.Change> filter) Accepts the constructor arguments ofTextFormatter(UnaryOperator)
and returns an instance ofTextFormatterBuilder<V>
.static <V> TextFormatterBuilder
<V> create
(StringConverter<V> valueConverter) Accepts the constructor arguments ofTextFormatter(StringConverter)
and returns an instance ofTextFormatterBuilder<V>
.static <V> TextFormatterBuilder
<V> create
(StringConverter<V> valueConverter, V defaultValue) Accepts the constructor arguments ofTextFormatter(StringConverter, V)
and returns an instance ofTextFormatterBuilder<V>
.static <V> TextFormatterBuilder
<V> create
(StringConverter<V> valueConverter, V defaultValue, UnaryOperator<TextFormatter.Change> filter) Accepts the constructor arguments ofTextFormatter(StringConverter, V, UnaryOperator)
and returns an instance ofTextFormatterBuilder<V>
.A builder method that invokes thesetValue
method on the instance being constructed.Applies a function to thevalueProperty
of the instance being constructed.
-
Method Details
-
create
Accepts the constructor arguments ofTextFormatter(UnaryOperator)
and returns an instance ofTextFormatterBuilder<V>
.- Returns:
- an instance of the
TextFormatterBuilder<V>
.
-
create
Accepts the constructor arguments ofTextFormatter(StringConverter)
and returns an instance ofTextFormatterBuilder<V>
.- Returns:
- an instance of the
TextFormatterBuilder<V>
.
-
create
Accepts the constructor arguments ofTextFormatter(StringConverter, V)
and returns an instance ofTextFormatterBuilder<V>
.- Returns:
- an instance of the
TextFormatterBuilder<V>
.
-
create
public static <V> TextFormatterBuilder<V> create(StringConverter<V> valueConverter, V defaultValue, UnaryOperator<TextFormatter.Change> filter) Accepts the constructor arguments ofTextFormatter(StringConverter, V, UnaryOperator)
and returns an instance ofTextFormatterBuilder<V>
.- Returns:
- an instance of the
TextFormatterBuilder<V>
.
-
build
Builds and returns an instance of theTextFormatter
class.Intermediate builder methods are not evaluated until the
build
method is called; in other words, they are evaluated lazily.- Returns:
- new instance of the
TextFormatter
class
-
apply
Applies a function to the TextFormatter instance being constructed. Most operations on the instance can be performed using this method.- Returns:
- builder instance
-
value
A builder method that invokes thesetValue
method on the instance being constructed.- Returns:
- builder instance
-
valuePropertyApply
Applies a function to thevalueProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.valueProperty().bind(anotherProperty)) // Use shorthand form .valuePropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-