Skip to content

Commit ab5e5d6

Browse files
committed
Add generic type to NodeBuilder interface
1 parent 5061a40 commit ab5e5d6

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

fx-builders/src/main/java/org/int4/fx/builders/common/AbstractNodeBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* @param <N> the type of {@link Node} being built
2121
* @param <B> the concrete builder type
2222
*/
23-
public abstract class AbstractNodeBuilder<N extends Node, B extends AbstractNodeBuilder<N, B>> extends AbstractOptionBuilder<N, B> implements NodeBuilder {
23+
public abstract class AbstractNodeBuilder<N extends Node, B extends AbstractNodeBuilder<N, B>> extends AbstractOptionBuilder<N, B> implements NodeBuilder<N> {
2424

2525
/**
2626
* Constructs a new instance with the given style classes.

fx-builders/src/main/java/org/int4/fx/builders/common/NodeBuilder.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import javafx.scene.control.Label;
99
import javafx.scene.control.Tooltip;
1010

11+
import org.int4.fx.builders.FX;
12+
1113
/**
1214
* Builder capable of creating a {@link Node}.
1315
* <p>
@@ -18,8 +20,10 @@
1820
* In such contexts, callers do not need to invoke {@link #build()} explicitly;
1921
* the builder will be completed automatically when a {@link Node} is required.
2022
* This enables fluent composition of builders without manual materialization.
23+
*
24+
* @param <N> the type of node being build
2125
*/
22-
public interface NodeBuilder {
26+
public interface NodeBuilder<N extends Node> {
2327

2428
/**
2529
* Converts the given object into a {@link Node}.
@@ -41,7 +45,7 @@ public interface NodeBuilder {
4145
static Node toNode(Object node) {
4246
return switch(node) {
4347
case Node n -> n;
44-
case NodeBuilder b -> b.build();
48+
case NodeBuilder<?> b -> b.build();
4549
case String s -> new Label(s);
4650
case null -> throw new IllegalArgumentException("node cannot be null");
4751
// TODO could also allow Observables to be translated to bound labels :)
@@ -75,5 +79,5 @@ static Node[] toNodes(Object... nodes) {
7579
*
7680
* @return a new {@link Node}, never {@code null}
7781
*/
78-
Node build();
82+
N build();
7983
}

0 commit comments

Comments
 (0)