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 Details

    • add

      void add​(JSONValue<?> value)
      Add a JSONValue
      Parameters:
      value - the JSONValue
    • addAll

      void addAll​(List<?> list)
      A a list of values. Each value is evaluated and converted to a JSON value
      Parameters:
      list - the list containing the values
    • insert

      void insert​(int index, JSONValue<?> value)
      Insert a JSONValue at a specified position
      Parameters:
      index - the position with the list
      value - the value
    • insert

      void insert​(int index, Object value)
      Insert a value at specified position. The value will be converted to a JSONValue
      Parameters:
      index - the position within the list to insert the value
      value - the raw value to be converted
    • get

      JSONValue<?> get​(int index)
      Return a JSONValue at a specified position
      Parameters:
      index - the position within the list of values
      Returns:
      the JSONValue
    • iterator

      Iterator<JSONValue<?>> iterator()
      Returns the iterator for this list. Allows for standard 'for' loops, and streaming with the Iterable.spliterator()
      Specified by:
      iterator in interface Iterable<JSONValue<?>>
    • remove

      JSONValue<?> remove​(int index)
      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

      List<JSONValue<?>> getValues()
      Return a list of JSONValues
      Returns:
      a List of JSONValue objects
    • toList

      <V> List<V> toList​(Class<?> targetClass)
      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

      List<Object> 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

      default JSONValue<?> getLast()
    • getFirst

      default JSONValue<?> getFirst()
      Return the first item in the list
      Returns:
      the first item in the list, or null if the list is empty