Record Class JsonArrayValue

java.lang.Object
java.lang.Record
io.github.mnesimiyilmaz.sql4json.json.JsonArrayValue
Record Components:
elements - the list of elements in this array
All Implemented Interfaces:
JsonValue

public record JsonArrayValue(List<JsonValue> elements) extends Record implements JsonValue
JSON array value.
  • Constructor Details

    • JsonArrayValue

      public JsonArrayValue(List<JsonValue> elements)
      Creates an instance of a JsonArrayValue record class.
      Parameters:
      elements - the value for the elements record component
  • Method Details

    • isNull

      public boolean isNull()
      Description copied from interface: JsonValue
      Returns true if this value is JSON null.
      Specified by:
      isNull in interface JsonValue
      Returns:
      true if null, false otherwise
    • isObject

      public boolean isObject()
      Description copied from interface: JsonValue
      Returns true if this value is a JSON object (key-value map).
      Specified by:
      isObject in interface JsonValue
      Returns:
      true if an object, false otherwise
    • isArray

      public boolean isArray()
      Description copied from interface: JsonValue
      Returns true if this value is a JSON array.
      Specified by:
      isArray in interface JsonValue
      Returns:
      true if an array, false otherwise
    • isNumber

      public boolean isNumber()
      Description copied from interface: JsonValue
      Returns true if this value is a JSON number (integer or floating-point).
      Specified by:
      isNumber in interface JsonValue
      Returns:
      true if a number, false otherwise
    • isString

      public boolean isString()
      Description copied from interface: JsonValue
      Returns true if this value is a JSON string.
      Specified by:
      isString in interface JsonValue
      Returns:
      true if a string, false otherwise
    • isBoolean

      public boolean isBoolean()
      Description copied from interface: JsonValue
      Returns true if this value is a JSON boolean.
      Specified by:
      isBoolean in interface JsonValue
      Returns:
      true if a boolean, false otherwise
    • asObject

      public Optional<Map<String,JsonValue>> asObject()
      Description copied from interface: JsonValue
      Returns the value as a JSON object (map of field names to values).
      Specified by:
      asObject in interface JsonValue
      Returns:
      the fields if this is an object, or Optional.empty() otherwise
    • asArray

      public Optional<List<JsonValue>> asArray()
      Description copied from interface: JsonValue
      Returns the value as a JSON array (ordered list of values).
      Specified by:
      asArray in interface JsonValue
      Returns:
      the elements if this is an array, or Optional.empty() otherwise
    • asNumber

      public Optional<Number> asNumber()
      Description copied from interface: JsonValue
      Returns the value as a Number.
      Specified by:
      asNumber in interface JsonValue
      Returns:
      the number if this is a numeric value, or Optional.empty() otherwise
    • asString

      public Optional<String> asString()
      Description copied from interface: JsonValue
      Returns the value as a String.
      Specified by:
      asString in interface JsonValue
      Returns:
      the string if this is a string value, or Optional.empty() otherwise
    • asBoolean

      public Optional<Boolean> asBoolean()
      Description copied from interface: JsonValue
      Returns the value as a Boolean.
      Specified by:
      asBoolean in interface JsonValue
      Returns:
      the boolean if this is a boolean value, or Optional.empty() otherwise
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • elements

      public List<JsonValue> elements()
      Returns the value of the elements record component.
      Returns:
      the value of the elements record component