Package com.apicatalog.tree.io
Class NativeAdapter
java.lang.Object
com.apicatalog.tree.io.NativeAdapter
- All Implemented Interfaces:
NodeAdapter
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final Objectadapt(Object value, NodeAdapter adapter) Converts the given node to aBigDecimal, if possible.asIterable(Object node) Returns the node as an iterable.Returns the node as a stream.Returns the string representation of the node, converting other types as needed.bigIntegerValue(Object node) Returns theBigIntegervalue of a number node.byte[]binaryValue(Object node) Returns the binary value of the node as a byte array.decimalValue(Object node) Returns theBigDecimalvalue of a number node.doubledoubleValue(Object node) Returns the double value of a number node.Returns the child nodes of a collection node as anIterable.elementStream(Object node) Returns the child nodes of a collection node as aStream.Returns all key-value pairs of the given map node as anIterable.entryStream(Object node) Returns all key-value pairs of the given map node as aStream.static final NativeAdapterinstance()intReturns the integer value of a number node.booleanChecks whether the node contains binary data.booleanChecks whether the node represents a boolean value.booleanisCollection(Object node) Checks whether the node represents a collection.booleanChecks whether a map node has no entries or a collection node has no items.booleanisIntegral(Object node) Checks whether a number node represents an integral value.booleanPreserves insertion order and can contain duplicates.booleanChecks whether the node represents a map (object) structure.booleanChecks whether the given object can be processed by this adapter.booleanChecks whether the node represents a null value.booleanChecks whether the node represents a numeric value.booleanContains only unique elements.booleanChecks whether the node represents a string value.Collection<? extends Object>Returns the collection of property key nodes for a map node.keyTypes()Returns the set of node types that are supported as keys in map nodes for this adapter.longReturns the long value of a number node.Returns the set of node types supported by this adapter.Returns the property value associated with the specified key node in a map node.intReturns the number of entries in a map node or items in a collection node.stringValue(Object node) Returns the string value of the node.Returns the type of the given node.
-
Field Details
-
VALUES
-
KEYS
-
INSTANCE
-
-
Constructor Details
-
NativeAdapter
public NativeAdapter()
-
-
Method Details
-
instance
-
isNode
Description copied from interface:NodeAdapterChecks whether the given object can be processed by this adapter.Returns true if the adapter is capable of handling the node type; false otherwise.
- Specified by:
isNodein interfaceNodeAdapter- Parameters:
node- the object to check- Returns:
- true if the node can be adapted by this adapter, false otherwise
-
nodeTypes
Description copied from interface:NodeAdapterReturns the set of node types supported by this adapter.- Specified by:
nodeTypesin interfaceNodeAdapter- Returns:
- a set of supported node types
-
type
Description copied from interface:NodeAdapterReturns the type of the given node.- Specified by:
typein interfaceNodeAdapter- Parameters:
node- the node to inspect- Returns:
- the
NodeTypeof the node
-
keyTypes
Description copied from interface:NodeAdapterReturns the set of node types that are supported as keys in map nodes for this adapter.- Specified by:
keyTypesin interfaceNodeAdapter- Returns:
- a set of supported key node types
-
keys
Description copied from interface:NodeAdapterReturns the collection of property key nodes for a map node.- Specified by:
keysin interfaceNodeAdapter- Parameters:
node- the map node- Returns:
- collection of property key nodes
-
property
Description copied from interface:NodeAdapterReturns the property value associated with the specified key node in a map node.- Specified by:
propertyin interfaceNodeAdapter- Parameters:
property- the property key nodenode- the map node containing the property- Returns:
- the property value node corresponding to the property key
-
entries
Description copied from interface:NodeAdapterReturns all key-value pairs of the given map node as anIterable.- Specified by:
entriesin interfaceNodeAdapter- Parameters:
node- the map node- Returns:
- iterable of key-value entries
-
entryStream
Description copied from interface:NodeAdapterReturns all key-value pairs of the given map node as aStream.- Specified by:
entryStreamin interfaceNodeAdapter- Parameters:
node- the map node- Returns:
- stream of key-value entries
-
elements
Description copied from interface:NodeAdapterReturns the child nodes of a collection node as anIterable.- Specified by:
elementsin interfaceNodeAdapter- Parameters:
node- the collection node- Returns:
- iterable of child nodes
-
elementStream
Description copied from interface:NodeAdapterReturns the child nodes of a collection node as aStream.- Specified by:
elementStreamin interfaceNodeAdapter- Parameters:
node- the collection node- Returns:
- stream of child nodes
-
stringValue
Description copied from interface:NodeAdapterReturns the string value of the node.- Specified by:
stringValuein interfaceNodeAdapter- Parameters:
node- the string node- Returns:
- string representation
-
intValue
Description copied from interface:NodeAdapterReturns the integer value of a number node.- Specified by:
intValuein interfaceNodeAdapter- Parameters:
node- the number node- Returns:
- integer value
-
longValue
Description copied from interface:NodeAdapterReturns the long value of a number node.- Specified by:
longValuein interfaceNodeAdapter- Parameters:
node- the number node- Returns:
- long value
-
bigIntegerValue
Description copied from interface:NodeAdapterReturns theBigIntegervalue of a number node.- Specified by:
bigIntegerValuein interfaceNodeAdapter- Parameters:
node- the number node- Returns:
- BigInteger value
-
doubleValue
Description copied from interface:NodeAdapterReturns the double value of a number node.- Specified by:
doubleValuein interfaceNodeAdapter- Parameters:
node- the number node- Returns:
- double value
-
decimalValue
Description copied from interface:NodeAdapterReturns theBigDecimalvalue of a number node.- Specified by:
decimalValuein interfaceNodeAdapter- Parameters:
node- the number node- Returns:
- BigDecimal value
-
binaryValue
Description copied from interface:NodeAdapterReturns the binary value of the node as a byte array.- Specified by:
binaryValuein interfaceNodeAdapter- Parameters:
node- the binary node- Returns:
- byte array representation
-
asIterable
Description copied from interface:NodeAdapterReturns the node as an iterable.If the node is null, returns an empty iterable. If it is a single element, wraps it as a singleton iterable. Useful for iterating without type checks.
- Specified by:
asIterablein interfaceNodeAdapter- Parameters:
node- the node to convert- Returns:
- iterable of elements
-
asStream
Description copied from interface:NodeAdapterReturns the node as a stream.- Specified by:
asStreamin interfaceNodeAdapter- Parameters:
node- the node to convert- Returns:
- stream of elements
-
isNull
Description copied from interface:NodeAdapterChecks whether the node represents a null value.- Specified by:
isNullin interfaceNodeAdapter- Parameters:
node- the node to check- Returns:
- true if the node is null, false otherwise
-
isBoolean
Description copied from interface:NodeAdapterChecks whether the node represents a boolean value.- Specified by:
isBooleanin interfaceNodeAdapter- Parameters:
node- the node to check- Returns:
- true if the node is a boolean, false otherwise
-
isMap
Description copied from interface:NodeAdapterChecks whether the node represents a map (object) structure.- Specified by:
isMapin interfaceNodeAdapter- Parameters:
node- the node to check- Returns:
- true if the node is a map, false otherwise
-
isCollection
Description copied from interface:NodeAdapterChecks whether the node represents a collection.- Specified by:
isCollectionin interfaceNodeAdapter- Parameters:
node- the node to check- Returns:
- true if the node is a collection, false otherwise
-
isList
Description copied from interface:NodeAdapterPreserves insertion order and can contain duplicates.- Specified by:
isListin interfaceNodeAdapter- Returns:
-
isSet
Description copied from interface:NodeAdapterContains only unique elements. Is unordered.- Specified by:
isSetin interfaceNodeAdapter- Returns:
-
isString
Description copied from interface:NodeAdapterChecks whether the node represents a string value.- Specified by:
isStringin interfaceNodeAdapter- Parameters:
node- the node to check- Returns:
- true if the node is a string, false otherwise
-
isNumber
Description copied from interface:NodeAdapterChecks whether the node represents a numeric value.- Specified by:
isNumberin interfaceNodeAdapter- Parameters:
node- the node to check- Returns:
- true if the node is numeric, false otherwise
-
isIntegral
Description copied from interface:NodeAdapterChecks whether a number node represents an integral value.Returns false for floating-point or
BigDecimalnodes.- Specified by:
isIntegralin interfaceNodeAdapter- Parameters:
node- the number node- Returns:
- true if the node is integral, false otherwise
-
isBinary
Description copied from interface:NodeAdapterChecks whether the node contains binary data.- Specified by:
isBinaryin interfaceNodeAdapter- Parameters:
node- the node to check- Returns:
- true if the node is binary, false otherwise
-
isEmpty
Description copied from interface:NodeAdapterChecks whether a map node has no entries or a collection node has no items.This method is intended for nodes of type
NodeType.MAPorNodeType.COLLECTION.- Specified by:
isEmptyin interfaceNodeAdapter- Parameters:
node- the node to inspect- Returns:
- true if the map has no entries or the collection has no items, false otherwise
-
size
Description copied from interface:NodeAdapterReturns the number of entries in a map node or items in a collection node.Intended for nodes of type
NodeType.MAPorNodeType.COLLECTION.- Specified by:
sizein interfaceNodeAdapter- Parameters:
node- the node to inspect- Returns:
- number of entries (for map) or items (for collection)
-
asString
Description copied from interface:NodeAdapterReturns the string representation of the node, converting other types as needed.- Specified by:
asStringin interfaceNodeAdapter- Parameters:
node- the node to convert- Returns:
- string representation
-
asDecimal
Description copied from interface:NodeAdapterConverts the given node to aBigDecimal, if possible.- Specified by:
asDecimalin interfaceNodeAdapter- Parameters:
node- the node to convert- Returns:
- BigDecimal representation of the node
-
adapt
-