Class TreeItemBuilder<T>
java.lang.Object
io.github.sosuisen.jfxbuilder.controls.TreeItemBuilder<T>
The
TreeItemBuilder
class constructs instances of the TreeItem
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 TreeItem
constructor
and returns an instance of the TreeItemBuilder
.
You can use method chaining to call the builder methods for configuring the TreeItem
.
Finally, invoke the build
method to generate an instance of the TreeItem
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 TypeMethodDescriptionfinal TreeItemBuilder
<T> addChildren
(Collection<? extends TreeItem<T>> col) Calls theaddAll
method on the ObservableList returned by theTreeItem#getChildren()
method.final TreeItemBuilder
<T> addChildren
(TreeItem<T>... elements) Calls theaddAll
method on the ObservableList returned by theTreeItem#getChildren()
method.Applies a function to the TreeItem instance being constructed.build()
Builds and returns an instance of theTreeItem
class.static <T> TreeItemBuilder
<T> create()
Returns an instance of theTreeItemBuilder<T>
.static <T> TreeItemBuilder
<T> create
(T value) Accepts the constructor arguments ofTreeItem(T)
and returns an instance ofTreeItemBuilder<T>
.static <T> TreeItemBuilder
<T> Accepts the constructor arguments ofTreeItem(T, Node)
and returns an instance ofTreeItemBuilder<T>
.expanded
(boolean value) A builder method that invokes thesetExpanded
method on the instance being constructed.Applies a function to theexpandedProperty
of the instance being constructed.A builder method that invokes thesetGraphic
method on the instance being constructed.Applies a function to thegraphicProperty
of the instance being constructed.Applies a function to theleafProperty
of the instance being constructed.Applies a function to theparentProperty
of the instance being constructed.A builder method that invokes thesetValue
method on the instance being constructed.Applies a function to thevalueProperty
of the instance being constructed.static <T> TreeItemBuilder
<T> withChildren
(Collection<? extends TreeItem<T>> col) Creates an instance of the builder, then calls theaddAll
method on the ObservableList returned by theTreeItem#getChildren()
method.static <T> TreeItemBuilder
<T> withChildren
(TreeItem<T>... elements) Creates an instance of the builder, then calls theaddAll
method on the ObservableList returned by theTreeItem#getChildren()
method.
-
Method Details
-
create
Returns an instance of theTreeItemBuilder<T>
.- Returns:
- an instance of the
TreeItemBuilder<T>
.
-
create
Accepts the constructor arguments ofTreeItem(T)
and returns an instance ofTreeItemBuilder<T>
.- Returns:
- an instance of the
TreeItemBuilder<T>
.
-
create
Accepts the constructor arguments ofTreeItem(T, Node)
and returns an instance ofTreeItemBuilder<T>
.- Returns:
- an instance of the
TreeItemBuilder<T>
.
-
build
Builds and returns an instance of theTreeItem
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
TreeItem
class
-
apply
Applies a function to the TreeItem instance being constructed. Most operations on the instance can be performed using this method.- Returns:
- builder instance
-
expanded
A builder method that invokes thesetExpanded
method on the instance being constructed.- Returns:
- builder instance
-
graphic
A builder method that invokes thesetGraphic
method on the instance being constructed.- Returns:
- builder instance
-
value
A builder method that invokes thesetValue
method on the instance being constructed.- Returns:
- builder instance
-
addChildren
Calls theaddAll
method on the ObservableList returned by theTreeItem#getChildren()
method.- Returns:
- builder instance
-
addChildren
Calls theaddAll
method on the ObservableList returned by theTreeItem#getChildren()
method.- Returns:
- builder instance
-
withChildren
Creates an instance of the builder, then calls theaddAll
method on the ObservableList returned by theTreeItem#getChildren()
method.- Returns:
- builder instance
-
withChildren
Creates an instance of the builder, then calls theaddAll
method on the ObservableList returned by theTreeItem#getChildren()
method.- Returns:
- builder instance
-
expandedPropertyApply
Applies a function to theexpandedProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.expandedProperty().bind(anotherProperty)) // Use shorthand form .expandedPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
graphicPropertyApply
Applies a function to thegraphicProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.graphicProperty().bind(anotherProperty)) // Use shorthand form .graphicPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
leafPropertyApply
Applies a function to theleafProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.leafProperty().bind(anotherProperty)) // Use shorthand form .leafPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
parentPropertyApply
Applies a function to theparentProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.parentProperty().bind(anotherProperty)) // Use shorthand form .parentPropertyApply(prop -> prop.bind(anotherProperty))
- 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
-