Class Arr<T extends Obj>

java.lang.Object
io.github.mxz_schwarz.parser.Obj
io.github.mxz_schwarz.parser.Arr<T>

public final class Arr<T extends Obj> extends Obj
Wrapper class for JSON arrays.
  • Constructor Details

    • Arr

      public Arr(List<T> val)
  • Method Details

    • toList

      public <E> List<E> toList(Class<E> clazz) throws JSONException
      Description copied from class: Obj
      Convenience method to cast each element in an array to a particular type.
      Overrides:
      toList in class Obj
      Parameters:
      clazz - The Class object representing the desired type.
      Returns:
      A list with generic type T.
      Throws:
      JSONException - If this Obj is not an Arr or when not every element is a T.
    • castElems

      public <E extends Obj> Arr<E> castElems(Class<E> clazz) throws JSONException
      Overrides:
      castElems in class Obj
      Throws:
      JSONException
    • toList

      public List<T> toList()
      Description copied from class: Obj
      Returns a List<Obj> when this represents an array.
      Overrides:
      toList in class Obj
      Returns:
      The value wrapped in this.
    • toStdLibObj

      public List<Object> toStdLibObj()
      Overrides:
      toStdLibObj in class Obj