Interface IValueStructureAccessor
-
- All Known Implementing Classes:
DefaultValueStructureAccessor
public interface IValueStructureAccessorAccessor for the structure of JSON-like values.- Since:
- 8.5.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ObjectasPrimitive(Object value)If the value is a primitive, returns the unwrapped primitive value.booleanisList(Object value)Checks if the given value is a list of items.booleanisMap(Object value)Checks 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).ObjectlistGet(Object list, int index)If the value is a list, gets the item at the given index.intlistSize(Object value)If the value is a list, gets the number of items in the list.ObjectmapGet(Object map, Object key)If the value is a map, gets the value for the given key.Collection<?>mapKeys(Object map)If the value is a map, gets the keys of the map.
-
-
-
Method Detail
-
asPrimitive
Object asPrimitive(Object value)
If the value is a primitive, returns the unwrapped primitive value. E.g. for a boolean, should return aBoolean. Unspecified behavior if the value is not a primitive.- Parameters:
value- The primitive value to access.- Returns:
- The primitive value.
-
isList
boolean isList(Object value)
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
boolean isMap(Object value)
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
boolean isPrimitive(Object value)
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
Object listGet(Object list, int index)
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
int listSize(Object value)
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
Object mapGet(Object map, Object key)
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
Collection<?> mapKeys(Object map)
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.
-
-