Class NodeUtil

java.lang.Object
net.officefloor.compile.impl.structure.NodeUtil

public class NodeUtil extends Object
Common utility functions for Node implementations.
Author:
Daniel Sagenschneider
  • Method Details

    • getNode

      public static <N extends Node> N getNode(String nodeName, Map<String,N> nodes, Supplier<N> create)
      Obtains the particular Node.
      Type Parameters:
      N - Node type.
      Parameters:
      nodeName - Name of the Node.
      nodes - Existing Map of Node instances by their names.
      create - Supplier to create the Node.
      Returns:
      Node for the name.
    • getInitialisedNode

      public static <N extends Node> N getInitialisedNode(String nodeName, Map<String,N> nodes, NodeContext context, Supplier<N> create, Consumer<N> initialiser)

      Obtains the initialised Node.

      Should the Node be already initialised, an issue will be reported to the CompilerIssues.

      Type Parameters:
      N - Node type.
      Parameters:
      nodeName - Name of the Node.
      nodes - Map of Node instances by their name.
      context - NodeContext.
      create - Supplier to create the Node.
      initialiser - Consumer to initialise the Node.
      Returns:
      Initialised Node.
    • getInitialisedNode

      public static <N extends Node> N getInitialisedNode(N existingNode, NodeContext context, Supplier<N> create, Consumer<N> initialiser)
      Obtains an initialised Node.
      Type Parameters:
      N - Node type.
      Parameters:
      existingNode - Existing Node. May be null.
      context - NodeContext.
      create - Supplier to create the Node.
      initialiser - Consumer to initialise the Node.
      Returns:
      Initialised Node.
    • initialise

      public static <S> S initialise(Node node, NodeContext context, S existingState, Supplier<S> createState)
      Initialises the Node.
      Type Parameters:
      S - Type of state.
      Parameters:
      node - Node to be initialised.
      context - NodeContext.
      existingState - Existing initialised state of the Node. May be null.
      createState - Supplier to create the initialised state.
      Returns:
      Initialised state for the Node.
    • isNodeTreeInitialised

      public static boolean isNodeTreeInitialised(Node root, CompilerIssues issues)
      Indicates if the Node tree is fully initialised.
      Parameters:
      root - Root Node of tree.
      issues - CompilerIssues.
      Returns:
      true if all Node instances within the tree are initialised. false if non-initialised Node instances within the tree, with issues reported to the CompilerIssues.
    • logTreeStructure

      public static void logTreeStructure(Node node, Writer log) throws IOException
      Logs the Node tree structure to the Writer.
      Parameters:
      node - Root Node of tree.
      log - Writer.
      Throws:
      IOException - If fails to log.
    • getLocation

      public static String getLocation(String sourceClassName, Object sourceInstance, String location)
      Obtains the location for the Node.
      Parameters:
      sourceClassName - Source Class name.
      sourceInstance - Instance of the source. May be null.
      location - Location of the source.
      Returns:
      Location for the Node.
    • getChildNodes

      @SafeVarargs public static Node[] getChildNodes(Map<String,? extends Node>... children)
      Obtains the child Node instances.
      Parameters:
      children - Map instances containing the child Node instances.
      Returns:
      Child Node instances.