Enum Class JSType

java.lang.Object
java.lang.Enum<JSType>
com.inductiveautomation.ignition.common.JSType
All Implemented Interfaces:
Serializable, Comparable<JSType>, Constable

public enum JSType extends Enum<JSType>
Represents the types possible in a JSON encoding.
  • Enum Constant Details

    • Number

      public static final JSType Number
    • String

      public static final JSType String
    • Boolean

      public static final JSType Boolean
    • Null

      public static final JSType Null
    • Object

      public static final JSType Object
    • Array

      public static final JSType Array
  • Method Details

    • values

      public static JSType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static JSType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • isPrimitive

      public boolean isPrimitive()
    • ofElement

      public static JSType ofElement(com.inductiveautomation.ignition.common.gson.JsonElement e)
    • ofObject

      public static JSType ofObject(Object object)
    • ofClass

      public static JSType ofClass(Class<?> clazz)
    • toJsonPrimitive

      public com.inductiveautomation.ignition.common.gson.JsonElement toJsonPrimitive(Object value)
    • getAsNumber

      public static Number getAsNumber(com.inductiveautomation.ignition.common.gson.JsonPrimitive element)
      This is a utility method that only exists because of an oddity in the GSON implementation. When GSON parses a number, it represents it as a LazilyParsedNumber. In many cases, we do not want one of these numbers, we want a more traditional subclass of Number like Double or Long. This method helps figure out which kind of number an element should really be and retrns that instead.
    • toJava

      public static Object toJava(com.inductiveautomation.ignition.common.gson.JsonPrimitive element)
      Converts a json primitive to the best representation for java (Number, Boolean or String)