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 theaddAllmethod on the ObservableList returned by theTreeItem#getChildren()method.final TreeItemBuilder<T> addChildren(TreeItem<T>... elements) Calls theaddAllmethod on the ObservableList returned by theTreeItem#getChildren()method.Applies a function to the TreeItem instance being constructed.build()Builds and returns an instance of theTreeItemclass.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 thesetExpandedmethod on the instance being constructed.Applies a function to theexpandedPropertyof the instance being constructed.A builder method that invokes thesetGraphicmethod on the instance being constructed.Applies a function to thegraphicPropertyof the instance being constructed.Applies a function to theleafPropertyof the instance being constructed.Applies a function to theparentPropertyof the instance being constructed.A builder method that invokes thesetValuemethod on the instance being constructed.Applies a function to thevaluePropertyof the instance being constructed.static <T> TreeItemBuilder<T> withChildren(Collection<? extends TreeItem<T>> col) Creates an instance of the builder, then calls theaddAllmethod on the ObservableList returned by theTreeItem#getChildren()method.static <T> TreeItemBuilder<T> withChildren(TreeItem<T>... elements) Creates an instance of the builder, then calls theaddAllmethod 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
-
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 thesetExpandedmethod on the instance being constructed.- Returns:
- builder instance
-
graphic
A builder method that invokes thesetGraphicmethod on the instance being constructed.- Returns:
- builder instance
-
value
A builder method that invokes thesetValuemethod on the instance being constructed.- Returns:
- builder instance
-
addChildren
Calls theaddAllmethod on the ObservableList returned by theTreeItem#getChildren()method.- Returns:
- builder instance
-
addChildren
Calls theaddAllmethod on the ObservableList returned by theTreeItem#getChildren()method.- Returns:
- builder instance
-
withChildren
Creates an instance of the builder, then calls theaddAllmethod on the ObservableList returned by theTreeItem#getChildren()method.- Returns:
- builder instance
-
withChildren
Creates an instance of the builder, then calls theaddAllmethod on the ObservableList returned by theTreeItem#getChildren()method.- Returns:
- builder instance
-
expandedPropertyApply
Applies a function to theexpandedPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.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 thegraphicPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.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 theleafPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.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 theparentPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.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 thevaluePropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.valueProperty().bind(anotherProperty)) // Use shorthand form .valuePropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-