Class NodeUtil
- java.lang.Object
-
- net.officefloor.compile.impl.structure.NodeUtil
-
public class NodeUtil extends java.lang.Object
Common utility functions forNode
implementations.- Author:
- Daniel Sagenschneider
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Node[]
getChildNodes(java.util.Map<java.lang.String,? extends Node>... children)
Obtains the childNode
instances.static <N extends Node>
NgetInitialisedNode(java.lang.String nodeName, java.util.Map<java.lang.String,N> nodes, NodeContext context, java.util.function.Supplier<N> create, java.util.function.Consumer<N> initialiser)
Obtains the initialisedNode
.static <N extends Node>
NgetInitialisedNode(N existingNode, NodeContext context, java.util.function.Supplier<N> create, java.util.function.Consumer<N> initialiser)
Obtains an initialisedNode
.static java.lang.String
getLocation(java.lang.String sourceClassName, java.lang.Object sourceInstance, java.lang.String location)
Obtains the location for theNode
.static <N extends Node>
NgetNode(java.lang.String nodeName, java.util.Map<java.lang.String,N> nodes, java.util.function.Supplier<N> create)
Obtains the particularNode
.static <S> S
initialise(Node node, NodeContext context, S existingState, java.util.function.Supplier<S> createState)
Initialises theNode
.static boolean
isNodeTreeInitialised(Node root, CompilerIssues issues)
Indicates if theNode
tree is fully initialised.static void
logTreeStructure(Node node, java.io.Writer log)
Logs theNode
tree structure to theWriter
.
-
-
-
Method Detail
-
getNode
public static <N extends Node> N getNode(java.lang.String nodeName, java.util.Map<java.lang.String,N> nodes, java.util.function.Supplier<N> create)
Obtains the particularNode
.
-
getInitialisedNode
public static <N extends Node> N getInitialisedNode(java.lang.String nodeName, java.util.Map<java.lang.String,N> nodes, NodeContext context, java.util.function.Supplier<N> create, java.util.function.Consumer<N> initialiser)
Obtains the initialised
Node
.Should the
Node
be already initialised, an issue will be reported to theCompilerIssues
.
-
getInitialisedNode
public static <N extends Node> N getInitialisedNode(N existingNode, NodeContext context, java.util.function.Supplier<N> create, java.util.function.Consumer<N> initialiser)
Obtains an initialisedNode
.
-
initialise
public static <S> S initialise(Node node, NodeContext context, S existingState, java.util.function.Supplier<S> createState)
Initialises theNode
.- Type Parameters:
S
- Type of state.- Parameters:
node
-Node
to be initialised.context
-NodeContext
.existingState
- Existing initialised state of theNode
. May benull
.createState
-Supplier
to create the initialised state.- Returns:
- Initialised state for the
Node
.
-
isNodeTreeInitialised
public static boolean isNodeTreeInitialised(Node root, CompilerIssues issues)
Indicates if theNode
tree is fully initialised.- Parameters:
root
- RootNode
of tree.issues
-CompilerIssues
.- Returns:
true
if allNode
instances within the tree are initialised.false
if non-initialisedNode
instances within the tree, with issues reported to theCompilerIssues
.
-
logTreeStructure
public static void logTreeStructure(Node node, java.io.Writer log) throws java.io.IOException
Logs theNode
tree structure to theWriter
.- Parameters:
node
- RootNode
of tree.log
-Writer
.- Throws:
java.io.IOException
- If fails to log.
-
getLocation
public static java.lang.String getLocation(java.lang.String sourceClassName, java.lang.Object sourceInstance, java.lang.String location)
Obtains the location for theNode
.- Parameters:
sourceClassName
- SourceClass
name.sourceInstance
- Instance of the source. May benull
.location
- Location of the source.- Returns:
- Location for the
Node
.
-
-