Package dev.polv.taleapi.config.json
Class JacksonConfigNode
java.lang.Object
dev.polv.taleapi.config.json.JacksonConfigNode
- All Implemented Interfaces:
ConfigNode
Jackson-based implementation of
ConfigNode.-
Constructor Summary
ConstructorsConstructorDescriptionJacksonConfigNode(com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.ObjectMapper mapper) Creates a new JacksonConfigNode wrapping the given JsonNode. -
Method Summary
Modifier and TypeMethodDescription<T> TConverts this node to a typed object.get(int index) Gets a child node by array index.Gets a child node by key.<T> TConverts a child node to a typed object.booleangetBoolean(String key) Gets a boolean value by key.booleangetBoolean(String key, boolean defaultValue) Gets a boolean value by key, with a default.doubleGets a double value by key.doubleGets a double value by key, with a default.intGets an integer value by key.intGets an integer value by key, with a default.getIntList(String key) Gets a list of integers by key.com.fasterxml.jackson.databind.JsonNodeReturns the underlying Jackson JsonNode.Gets a list of child nodes by key.longGets a long value by key.longGets a long value by key, with a default.getOptionalBoolean(String key) Gets an optional boolean value by key.getOptionalDouble(String key) Gets an optional double value by key.getOptionalInt(String key) Gets an optional integer value by key.getOptionalLong(String key) Gets an optional long value by key.getOptionalString(String key) Gets an optional string value by key.Gets a string value by key.Gets a string value by key, with a default.getStringList(String key) Gets a list of strings by key.booleanChecks if a key exists in this object node.booleanisArray()Checks if this node represents a JSON array.booleanisNull()Checks if this node is null or missing.booleanisObject()Checks if this node represents a JSON object (key-value pairs).booleanisValue()Checks if this node represents a primitive value (string, number, boolean).keys()Returns all keys in this object node.rawValue()Gets this node's value as a raw Object.intsize()Returns the number of elements in this node.toJson()Returns the JSON string representation of this node.Returns the pretty-printed JSON string representation of this node.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface dev.polv.taleapi.config.ConfigNode
getSection
-
Constructor Details
-
JacksonConfigNode
public JacksonConfigNode(com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.databind.ObjectMapper mapper) Creates a new JacksonConfigNode wrapping the given JsonNode.- Parameters:
node- the Jackson JsonNodemapper- the ObjectMapper for conversions
-
-
Method Details
-
getJsonNode
public com.fasterxml.jackson.databind.JsonNode getJsonNode()Returns the underlying Jackson JsonNode.- Returns:
- the JsonNode
-
isObject
public boolean isObject()Description copied from interface:ConfigNodeChecks if this node represents a JSON object (key-value pairs).- Specified by:
isObjectin interfaceConfigNode- Returns:
- true if this node is an object
-
isArray
public boolean isArray()Description copied from interface:ConfigNodeChecks if this node represents a JSON array.- Specified by:
isArrayin interfaceConfigNode- Returns:
- true if this node is an array
-
isValue
public boolean isValue()Description copied from interface:ConfigNodeChecks if this node represents a primitive value (string, number, boolean).- Specified by:
isValuein interfaceConfigNode- Returns:
- true if this node is a value
-
isNull
public boolean isNull()Description copied from interface:ConfigNodeChecks if this node is null or missing.- Specified by:
isNullin interfaceConfigNode- Returns:
- true if this node is null
-
has
Description copied from interface:ConfigNodeChecks if a key exists in this object node.Supports dot notation for nested paths:
"database.host"- Specified by:
hasin interfaceConfigNode- Parameters:
key- the key or path to check- Returns:
- true if the key exists
-
keys
Description copied from interface:ConfigNodeReturns all keys in this object node.- Specified by:
keysin interfaceConfigNode- Returns:
- set of keys, or empty set if not an object
-
size
public int size()Description copied from interface:ConfigNodeReturns the number of elements in this node.For objects, returns the number of keys. For arrays, returns the number of elements. For values, returns 1.
- Specified by:
sizein interfaceConfigNode- Returns:
- the size of this node
-
get
Description copied from interface:ConfigNodeGets a child node by key.Supports dot notation for nested paths:
"database.host"- Specified by:
getin interfaceConfigNode- Parameters:
key- the key or path- Returns:
- the child node, or a null node if not found
-
get
Description copied from interface:ConfigNodeGets a child node by array index.- Specified by:
getin interfaceConfigNode- Parameters:
index- the array index- Returns:
- the child node, or a null node if out of bounds
-
getString
Description copied from interface:ConfigNodeGets a string value by key.- Specified by:
getStringin interfaceConfigNode- Parameters:
key- the key or path- Returns:
- the string value
-
getString
Description copied from interface:ConfigNodeGets a string value by key, with a default.- Specified by:
getStringin interfaceConfigNode- Parameters:
key- the key or pathdefaultValue- the default value if key doesn't exist- Returns:
- the string value or default
-
getOptionalString
Description copied from interface:ConfigNodeGets an optional string value by key.- Specified by:
getOptionalStringin interfaceConfigNode- Parameters:
key- the key or path- Returns:
- an Optional containing the value, or empty if not found
-
getInt
Description copied from interface:ConfigNodeGets an integer value by key.- Specified by:
getIntin interfaceConfigNode- Parameters:
key- the key or path- Returns:
- the integer value
-
getInt
Description copied from interface:ConfigNodeGets an integer value by key, with a default.- Specified by:
getIntin interfaceConfigNode- Parameters:
key- the key or pathdefaultValue- the default value if key doesn't exist- Returns:
- the integer value or default
-
getOptionalInt
Description copied from interface:ConfigNodeGets an optional integer value by key.- Specified by:
getOptionalIntin interfaceConfigNode- Parameters:
key- the key or path- Returns:
- an Optional containing the value, or empty if not found
-
getLong
Description copied from interface:ConfigNodeGets a long value by key.- Specified by:
getLongin interfaceConfigNode- Parameters:
key- the key or path- Returns:
- the long value
-
getLong
Description copied from interface:ConfigNodeGets a long value by key, with a default.- Specified by:
getLongin interfaceConfigNode- Parameters:
key- the key or pathdefaultValue- the default value if key doesn't exist- Returns:
- the long value or default
-
getOptionalLong
Description copied from interface:ConfigNodeGets an optional long value by key.- Specified by:
getOptionalLongin interfaceConfigNode- Parameters:
key- the key or path- Returns:
- an Optional containing the value, or empty if not found
-
getDouble
Description copied from interface:ConfigNodeGets a double value by key.- Specified by:
getDoublein interfaceConfigNode- Parameters:
key- the key or path- Returns:
- the double value
-
getDouble
Description copied from interface:ConfigNodeGets a double value by key, with a default.- Specified by:
getDoublein interfaceConfigNode- Parameters:
key- the key or pathdefaultValue- the default value if key doesn't exist- Returns:
- the double value or default
-
getOptionalDouble
Description copied from interface:ConfigNodeGets an optional double value by key.- Specified by:
getOptionalDoublein interfaceConfigNode- Parameters:
key- the key or path- Returns:
- an Optional containing the value, or empty if not found
-
getBoolean
Description copied from interface:ConfigNodeGets a boolean value by key.- Specified by:
getBooleanin interfaceConfigNode- Parameters:
key- the key or path- Returns:
- the boolean value
-
getBoolean
Description copied from interface:ConfigNodeGets a boolean value by key, with a default.- Specified by:
getBooleanin interfaceConfigNode- Parameters:
key- the key or pathdefaultValue- the default value if key doesn't exist- Returns:
- the boolean value or default
-
getOptionalBoolean
Description copied from interface:ConfigNodeGets an optional boolean value by key.- Specified by:
getOptionalBooleanin interfaceConfigNode- Parameters:
key- the key or path- Returns:
- an Optional containing the value, or empty if not found
-
getList
Description copied from interface:ConfigNodeGets a list of child nodes by key.- Specified by:
getListin interfaceConfigNode- Parameters:
key- the key or path- Returns:
- list of ConfigNode elements
-
getStringList
Description copied from interface:ConfigNodeGets a list of strings by key.- Specified by:
getStringListin interfaceConfigNode- Parameters:
key- the key or path- Returns:
- list of strings
-
getIntList
Description copied from interface:ConfigNodeGets a list of integers by key.- Specified by:
getIntListin interfaceConfigNode- Parameters:
key- the key or path- Returns:
- list of integers
-
as
Description copied from interface:ConfigNodeConverts this node to a typed object.- Specified by:
asin interfaceConfigNode- Type Parameters:
T- the type- Parameters:
type- the class to convert to- Returns:
- the converted object
-
get
Description copied from interface:ConfigNodeConverts a child node to a typed object.- Specified by:
getin interfaceConfigNode- Type Parameters:
T- the type- Parameters:
key- the key or pathtype- the class to convert to- Returns:
- the converted object
-
rawValue
Description copied from interface:ConfigNodeGets this node's value as a raw Object.Returns:
- String, Number, Boolean for primitives
- List for arrays
- Map for objects
- null for null nodes
- Specified by:
rawValuein interfaceConfigNode- Returns:
- the raw value
-
toJson
Description copied from interface:ConfigNodeReturns the JSON string representation of this node.- Specified by:
toJsonin interfaceConfigNode- Returns:
- JSON string
-
toPrettyJson
Description copied from interface:ConfigNodeReturns the pretty-printed JSON string representation of this node.- Specified by:
toPrettyJsonin interfaceConfigNode- Returns:
- pretty-printed JSON string
-
toString
-