Package io.apicurio.datamodels.util
Class NodeUtil
- java.lang.Object
-
- io.apicurio.datamodels.util.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 Summary
Constructors Constructor Description NodeUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String[]asArray(List<String> list)Turns a list into an array.static List<String>asList(String... items)Creates a list from a bunch of argument items.static List<String>copyList(List<String> list)Makes a copy of a list.static booleanequals(Object value1, Object value2)Tests two objects for equality.static ObjectgetMapItem(Map map, String key)Gets an item out of a map.static Collection<String>getMapKeys(Map<String,?> map)Gets the keys from the given map.static <T> Collection<T>getMapValues(Map<String,T> map)Gets the values from the given map.static ObjectgetNodeProperty(Node node, String propertyName)Returns the value for a given node property.static ObjectgetProperty(Object node, String propertyName)static booleanisDefined(Object value)Returns true if the given value is defined (ie if the value is NOT null or undefined).static booleanisDefinition(Node node)Return true if the given node is a definition.static booleanisList(Object object)Returns true if the given object is a list.static booleanisMap(Object object)Returns true if the given object is a list.static booleanisNode(Object object)Return true if the given object is a Node.static booleanisNullOrUndefined(Object value)Returns true if the given value is null or undefined.static booleanisUnion(Object object)Return true if the given object is a Union type.static voidsetProperty(Object node, String propertyName, Object newValue)static inttoInteger(String value)Converts a string value to an integer (it's expected to be formatted as an int).
-
-
-
Method Detail
-
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-
-
-