Interface JsonElement

All Known Implementing Classes:
JsonArray, JsonBoolean, JsonNull, JsonNumber, JsonObject, JsonString, TraceableJsonObject, UserJsonString

public interface JsonElement
Common Interface for all Json metamodel Elements (e.g., JsonArray, JsonBoolean,...). By default, all methods for checking the concrete type of a metamodel element (e.g., isJsonArray()) return false. In each concrete type, the respective method must be overridden to return true. This avoids instanceof expressions. Similarly, the getAs methods (e.g., getAsJsonArray()) return an error if they are called. In each concrete type, the respective method must be overridden to return "this". This avoids down casts to the concrete type.
  • Method Details

    • isJsonObject

      default boolean isJsonObject()
      Returns:
      true iff this object is of type JsonObject and false otherwise.
    • isJsonArray

      default boolean isJsonArray()
      Returns:
      true iff this object is of type JsonArray and false otherwise.
    • isJsonBoolean

      default boolean isJsonBoolean()
      Returns:
      true iff this object is of type JsonBoolean and false otherwise.
    • isJsonString

      default boolean isJsonString()
      Returns:
      true iff this object is of type JsonString and false otherwise.
    • isJsonNumber

      default boolean isJsonNumber()
      Returns:
      true iff this object is of type JsonNumber and false otherwise.
    • isJsonNull

      default boolean isJsonNull()
      Returns:
      true iff this object is of type JsonNull and false otherwise.
    • getAsJsonObject

      default JsonObject getAsJsonObject()
      Returns:
      this object as JsonObject if it is of this type and throws an error otherwise.
    • getAsJsonArray

      default JsonArray getAsJsonArray()
      Returns:
      this object as JsonArray if it is of this type and throws an error otherwise.
    • getAsJsonBoolean

      default JsonBoolean getAsJsonBoolean()
      Returns:
      this object as JsonBoolean if it is of this type and throws an error otherwise.
    • getAsJsonString

      default JsonString getAsJsonString()
      Returns:
      this object as JsonString if it is of this type and throws an error otherwise.
    • getAsJsonNumber

      default JsonNumber getAsJsonNumber()
      Returns:
      this object as JsonNumber if it is of this type and throws an error otherwise.
    • getAsJsonNull

      default JsonNull getAsJsonNull()
      Returns:
      this object as JsonNull if it is of this type and throws an error otherwise.
    • print