Class NodeUtil
- java.lang.Object
-
- net.officefloor.compile.impl.structure.NodeUtil
-
public class NodeUtil extends java.lang.ObjectCommon utility functions forNodeimplementations.- 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 childNodeinstances.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.StringgetLocation(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> Sinitialise(Node node, NodeContext context, S existingState, java.util.function.Supplier<S> createState)Initialises theNode.static booleanisNodeTreeInitialised(Node root, CompilerIssues issues)Indicates if theNodetree is fully initialised.static voidlogTreeStructure(Node node, java.io.Writer log)Logs theNodetree 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
Nodebe 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-Nodeto be initialised.context-NodeContext.existingState- Existing initialised state of theNode. May benull.createState-Supplierto create the initialised state.- Returns:
- Initialised state for the
Node.
-
isNodeTreeInitialised
public static boolean isNodeTreeInitialised(Node root, CompilerIssues issues)
Indicates if theNodetree is fully initialised.- Parameters:
root- RootNodeof tree.issues-CompilerIssues.- Returns:
trueif allNodeinstances within the tree are initialised.falseif non-initialisedNodeinstances within the tree, with issues reported to theCompilerIssues.
-
logTreeStructure
public static void logTreeStructure(Node node, java.io.Writer log) throws java.io.IOException
Logs theNodetree structure to theWriter.- Parameters:
node- RootNodeof 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- SourceClassname.sourceInstance- Instance of the source. May benull.location- Location of the source.- Returns:
- Location for the
Node.
-
-