Class NodeUtil


  • public class NodeUtil
    extends Object
    A utility class containing methods used to interact with data model nodes. Anything that needs to be handled differently (with respect to data model nodes) in Java vs. TS/JS should be done here. There is a NodeUtil.ts file that contains the TS/JS specific implementation of this class.
    Author:
    eric.wittmann@gmail.com
    • Constructor Detail

      • NodeUtil

        public NodeUtil()
    • Method Detail

      • setProperty

        public static void setProperty​(Object node,
                                       String propertyName,
                                       Object newValue)
      • getNodeProperty

        public static Object getNodeProperty​(Node node,
                                             String propertyName)
        Returns the value for a given node property.
        Parameters:
        node -
        propertyName -
      • isNode

        public static boolean isNode​(Object object)
        Return true if the given object is a Node.
        Parameters:
        object -
      • isDefinition

        public static boolean isDefinition​(Node node)
        Return true if the given node is a definition. A node is a definition in both AsyncAPI and OpenAPI if it is defined in a way that makes it reusable elsewhere in the document.
        Parameters:
        node -
      • isUnion

        public static boolean isUnion​(Object object)
        Return true if the given object is a Union type.
        Parameters:
        object -
      • isList

        public static boolean isList​(Object object)
        Returns true if the given object is a list.
        Parameters:
        object -
      • isMap

        public static boolean isMap​(Object object)
        Returns true if the given object is a list.
        Parameters:
        object -
      • getMapItem

        public static Object getMapItem​(Map map,
                                        String key)
        Gets an item out of a map. Needed due to transpilation wierdness.
        Parameters:
        map -
        key -
      • toInteger

        public static int toInteger​(String value)
        Converts a string value to an integer (it's expected to be formatted as an int).
        Parameters:
        value -
      • isNullOrUndefined

        public static boolean isNullOrUndefined​(Object value)
        Returns true if the given value is null or undefined.
        Parameters:
        value -
      • isDefined

        public static boolean isDefined​(Object value)
        Returns true if the given value is defined (ie if the value is NOT null or undefined).
        Parameters:
        value -
      • asList

        public static List<String> asList​(String... items)
        Creates a list from a bunch of argument items.
        Parameters:
        items -
      • asArray

        public static String[] asArray​(List<String> list)
        Turns a list into an array.
        Parameters:
        list -
      • copyList

        public static List<String> copyList​(List<String> list)
        Makes a copy of a list.
        Parameters:
        list -
      • equals

        public static boolean equals​(Object value1,
                                     Object value2)
        Tests two objects for equality.
        Parameters:
        value1 -
        value2 -
      • getMapKeys

        public static Collection<String> getMapKeys​(Map<String,​?> map)
        Gets the keys from the given map.
        Parameters:
        map -
      • getMapValues

        public static <T> Collection<T> getMapValues​(Map<String,​T> map)
        Gets the values from the given map.
        Parameters:
        map -