Interface IValueStructureAccessor
- All Known Implementing Classes:
DefaultValueStructureAccessor
public interface IValueStructureAccessor
Accessor for the structure of JSON-like values.
- Since:
- 8.5.0
-
Method Summary
Modifier and TypeMethodDescriptionasPrimitive(Object value) If the value is a primitive, returns the unwrapped primitive value.booleanChecks if the given value is a list of items.booleanChecks if the given value is a map of key-value pairs.booleanisPrimitive(Object value) Checks if the given value is a primitive value, i.e. not a container (list or map).If the value is a list, gets the item at the given index.intIf the value is a list, gets the number of items in the list.If the value is a map, gets the value for the given key.Collection<?> If the value is a map, gets the keys of the map.
-
Method Details
-
asPrimitive
-
isList
Checks if the given value is a list of items.- Parameters:
value- The value to check.- Returns:
- True if the value is a list, false otherwise.
-
isMap
Checks if the given value is a map of key-value pairs.- Parameters:
value- The value to check.- Returns:
- True if the value is a map, false otherwise.
-
isPrimitive
Checks if the given value is a primitive value, i.e. not a container (list or map).- Parameters:
value- The value to check.- Returns:
- True if the value is a primitive, false otherwise.
-
listGet
If the value is a list, gets the item at the given index. Unspecified behavior if the value is not a list.- Parameters:
list- The list with items to access.index- The index of the item to access.- Returns:
- The item at the given index.
- Throws:
IndexOutOfBoundsException- if the index is out of bounds.
-
listSize
If the value is a list, gets the number of items in the list. Unspecified behavior if the value is not a list.- Parameters:
value- The list to get the size of.- Returns:
- The number of items in the list.
-
mapGet
If the value is a map, gets the value for the given key. Unspecified behavior if the value is not a map.- Parameters:
map- The map with key-value pairs to access.key- The key of the value to access.- Returns:
- The value for the given key, or null if the key does not exist in the map.
-
mapKeys
If the value is a map, gets the keys of the map. Unspecified behavior if the value is not a map.- Parameters:
map- The map with key-value pairs to access.- Returns:
- The keys of the map.
-