Class ProcessorDefinitionHelper

java.lang.Object
org.apache.camel.model.ProcessorDefinitionHelper

public final class ProcessorDefinitionHelper extends Object
Helper class for ProcessorDefinition and the other model classes.
  • Method Details

    • filterTypeInOutputs

      public static <T> Collection<T> filterTypeInOutputs(List<ProcessorDefinition<?>> outputs, Class<T> type)
      Looks for the given type in the list of outputs and recurring all the children as well.
      Parameters:
      outputs - list of outputs, can be null or empty.
      type - the type to look for
      Returns:
      the found definitions, or null if not found
    • filterTypeInOutputs

      public static <T> Collection<T> filterTypeInOutputs(List<ProcessorDefinition<?>> outputs, Class<T> type, int maxDeep)
      Looks for the given type in the list of outputs and recurring all the children as well.
      Parameters:
      outputs - list of outputs, can be null or empty.
      type - the type to look for
      maxDeep - maximum levels deep to traverse
      Returns:
      the found definitions, or null if not found
    • findFirstTypeInOutputs

      public static <T> T findFirstTypeInOutputs(List<ProcessorDefinition<?>> outputs, Class<T> type)
      Looks for the given type in the list of outputs and recurring all the children as well. Will stop at first found and return it.
      Parameters:
      outputs - list of outputs, can be null or empty.
      type - the type to look for
      Returns:
      the first found type, or null if not found
    • isFirstChildOfType

      public static boolean isFirstChildOfType(Class<?> parentType, ProcessorDefinition<?> node)
      Is the given child the first in the outputs from the parent?
      Parameters:
      parentType - the type the parent must be
      node - the node
      Returns:
      true if first child, false otherwise
    • isParentOfType

      public static boolean isParentOfType(Class<? extends ProcessorDefinition> parentType, ProcessorDefinition<?> node, boolean recursive)
      Is the given node parent(s) of the given type
      Parameters:
      parentType - the parent type
      node - the current node
      recursive - whether or not to check grand parent(s) as well
      Returns:
      true if parent(s) is of given type, false otherwise
    • findFirstParentOfType

      public static <T extends ProcessorDefinition> T findFirstParentOfType(Class<T> parentType, ProcessorDefinition<?> node, boolean recursive)
      Is the given node parent(s) of the given type
      Parameters:
      parentType - the parent type
      node - the current node
      recursive - whether or not to check grand parent(s) as well
      Returns:
      true if parent(s) is of given type, false otherwise
    • getRoute

      public static RouteDefinition getRoute(org.apache.camel.NamedNode node)
      Gets the route definition the given node belongs to.
      Parameters:
      node - the node
      Returns:
      the route, or null if not possible to find
    • getRouteId

      public static String getRouteId(org.apache.camel.NamedNode node)
      Gets the route id the given node belongs to.
      Parameters:
      node - the node
      Returns:
      the route id, or null if not possible to find
    • gatherAllNodeIds

      public static Set<String> gatherAllNodeIds(ProcessorDefinition<?> node, Set<String> set, boolean onlyCustomId, boolean includeAbstract)
      Traverses the node, including its children (recursive), and gathers all the node ids.
      Parameters:
      node - the target node
      set - set to store ids, if null a new set will be created
      onlyCustomId - whether to only store custom assigned ids (ie. OptionalIdentifiedDefinition.hasCustomIdAssigned()
      includeAbstract - whether to include abstract nodes (ie. ProcessorDefinition.isAbstract()
      Returns:
      the set with the found ids.
    • resetAllAutoAssignedNodeIds

      public static void resetAllAutoAssignedNodeIds(ProcessorDefinition<?> node)
      Resets (nulls) all the auto assigned ids on the node and the nested children (outputs)
    • prepareSourceLocation

      public static void prepareSourceLocation(org.apache.camel.spi.Resource resource, org.apache.camel.NamedNode node)
      Prepares the output to gather source location:line-number if possible. This operation is slow as it uses StackTrace so this should only be used when Camel Debugger is enabled.
      Parameters:
      node - the node
    • getNodeLevel

      public static int getNodeLevel(org.apache.camel.NamedNode node)
      Returns the level of the node in the route tree. Level 1 is the root level, level 2 is a child of an EIP, and so forth
    • findParentSourceLocationScheme

      public static String findParentSourceLocationScheme(org.apache.camel.NamedNode node)
      Finds the source location scheme from the parent nodes.