Class PrimitiveUtils


  • public final class PrimitiveUtils
    extends java.lang.Object
    The PrimitiveUtils class provides a range of utilities for working with primitives. The class provides static members only and serves as a namespace.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  PrimitiveUtils.PathCounter
      The PathCounter class helps count the number of possible paths from a source (parent) primitive to a target (child) primitive.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int countNonJunctionParents​(Primitive primitive)
      Counts non-junction parents of the given primitive.
      static int getChildCount​(PrimitiveAnd root, Primitive.Kind kind)
      Counts the number of childs (arguments) that have a specific type for the given primitive.
      static boolean isJunction​(Primitive primitive)
      Checks whether the given primitive is a junction.
      static boolean isLeaf​(Primitive primitive)
      Checks whether the given primitive is a leaf primitive.
      static void saveAllOrsToList​(Primitive source, java.util.List<PrimitiveAnd> destination)
      Saves all AND primitives associated with the current primitive by using OR rules to a list.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • saveAllOrsToList

        public static void saveAllOrsToList​(Primitive source,
                                            java.util.List<PrimitiveAnd> destination)
        Saves all AND primitives associated with the current primitive by using OR rules to a list. Nested OR rules are resolved recursively. If the current primitive is an AND rule, it is places to the list and the method returns.
        Parameters:
        source - A primitives that serves as a source.
        destination - The list to which AND rules are to be saved.
        Throws:
        java.lang.NullPointerException - if any of the parameters equals null.
      • getChildCount

        public static int getChildCount​(PrimitiveAnd root,
                                        Primitive.Kind kind)
        Counts the number of childs (arguments) that have a specific type for the given primitive.
        Parameters:
        root - Root primitive.
        kind - Type of child primitives to be counted.
        Returns:
        Number of childs of the given type.
        Throws:
        java.lang.NullPointerException - if any of the parameters equals null.
      • isLeaf

        public static boolean isLeaf​(Primitive primitive)
        Checks whether the given primitive is a leaf primitive. A primitive is considered a leaf it does not have childs (arguments) of the same type. An OR rule cannot be a leaf.
        Parameters:
        primitive - Primitive to be checked.
        Returns:
        true if the primitive is a leaf or false otherwise.
        Throws:
        java.lang.NullPointerException - if the parameter equals null.
      • isJunction

        public static boolean isJunction​(Primitive primitive)
        Checks whether the given primitive is a junction. A junction is an AND-rule primitive that has more than one child primitive (argument) of the same type as the junction primitive itself. An OR rule is not a junction.
        Parameters:
        primitive - Primitive to be checked.
        Returns:
        true if the primitive is a junction or false otherwise.
        Throws:
        java.lang.NullPointerException - if the parameter equals null.
      • countNonJunctionParents

        public static int countNonJunctionParents​(Primitive primitive)
        Counts non-junction parents of the given primitive.
        Parameters:
        primitive - Primitive to be checked.
        Returns:
        number of non-junction parents.
        Throws:
        java.lang.NullPointerException - if the parameter equals null.