Package org.ghotibeaun.json
Interface JSONListNode
- All Superinterfaces:
Comparable<JSONNode>
,Iterable<JSONValue<?>>
,JSONNode
,Serializable
- All Known Subinterfaces:
JSONArray
public interface JSONListNode extends JSONNode, Iterable<JSONValue<?>>
Base interface for managing list/array values
- Author:
- Jim Earley (jim.earley@fdiinc.com)
-
Method Summary
Modifier and Type Method Description void
add(JSONValue<?> value)
Add a JSONValuevoid
addAll(List<?> list)
A a list of values.void
clear()
Clear the listJSONValue<?>
get(int index)
Return a JSONValue at a specified positiondefault JSONValue<?>
getFirst()
Return the first item in the listdefault JSONValue<?>
getLast()
List<Object>
getList()
Return a list of Objects.List<JSONValue<?>>
getValues()
Return a list of JSONValuesvoid
insert(int index, Object value)
Insert a value at specified position.void
insert(int index, JSONValue<?> value)
Insert a JSONValue at a specified positiondefault boolean
isEmpty()
Returns whether the list is emptydefault boolean
isNull(int index)
Returns whether a value at a specified position is a null valueIterator<JSONValue<?>>
iterator()
Returns the iterator for this list.JSONValue<?>
remove(int index)
Remove a value at a specified positionint
size()
Return the current length of the list<V> List<V>
toList(Class<?> targetClass)
Converts a list of JSONValues into a list of valuesMethods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface org.ghotibeaun.json.JSONNode
asJSONArray, asJSONObject, isArray, isEquivalent, isObject, prettyPrint, prettyPrint, select, select, select, selectValue, selectValue, selectValue, toJSONString, write, write, write, write, write, write, write, write
-
Method Details
-
add
Add a JSONValue- Parameters:
value
- the JSONValue
-
addAll
A a list of values. Each value is evaluated and converted to a JSON value- Parameters:
list
- the list containing the values
-
insert
Insert a JSONValue at a specified position- Parameters:
index
- the position with the listvalue
- the value
-
insert
Insert a value at specified position. The value will be converted to a JSONValue- Parameters:
index
- the position within the list to insert the valuevalue
- the raw value to be converted
-
get
Return a JSONValue at a specified position- Parameters:
index
- the position within the list of values- Returns:
- the JSONValue
-
iterator
Returns the iterator for this list. Allows for standard 'for' loops, and streaming with theIterable.spliterator()
-
remove
Remove a value at a specified position- Parameters:
index
- the position within the list- Returns:
- the JSONValue removed
-
clear
void clear()Clear the list -
size
int size()Return the current length of the list- Returns:
- the current length of the list
-
isEmpty
default boolean isEmpty()Returns whether the list is empty- Returns:
- true if empty; false otherwise
-
getValues
Return a list of JSONValues- Returns:
- a List of JSONValue objects
-
toList
Converts a list of JSONValues into a list of values- Type Parameters:
V
- The internal type for each value- Parameters:
targetClass
- the targetClass for each value- Returns:
- the List of values
-
isNull
default boolean isNull(int index)Returns whether a value at a specified position is a null value- Parameters:
index
- the position within the list- Returns:
- true if the value is null; false otherwise
-
getList
Return a list of Objects. Primitive values will be converted accordingly. JSONArrays will be converted to List, and JSONObject will be converted to Map- Returns:
- a list of values
-
getLast
-
getFirst
Return the first item in the list- Returns:
- the first item in the list, or null if the list is empty
-