Class KsqlObject


  • public class KsqlObject
    extends Object
    A representation of a map of string keys to values. Useful for representing a JSON object.
    • Constructor Detail

      • KsqlObject

        public KsqlObject()
        Creates an empty instance.
      • KsqlObject

        public KsqlObject​(Map<String,​Object> map)
        Creates an instance with the specified entries.
        Parameters:
        map - the entries
    • Method Detail

      • containsKey

        public boolean containsKey​(String key)
        Returns whether the map contains the specified key.
        Parameters:
        key - the key
        Returns:
        whether the map contains the key
      • fieldNames

        public Set<String> fieldNames()
        Returns the keys of the map.
        Returns:
        the keys
      • size

        public int size()
        Returns the size (number of entries) of the map.
        Returns:
        the size
      • isEmpty

        public boolean isEmpty()
        Returns whether the map is empty.
        Returns:
        whether the map is empty
      • getMap

        public Map<String,​Object> getMap()
        Returns the entries of the map as a Map.
        Returns:
        the entries
      • getValue

        public Object getValue​(String key)
        Returns the value associated with the specified key as an Object. Returns null if the key is not present.
        Parameters:
        key - the key
        Returns:
        the value
      • getString

        public String getString​(String key)
        Returns the value associated with the specified key as a string. Returns null if the key is not present.
        Parameters:
        key - the key
        Returns:
        the value
        Throws:
        ClassCastException - if the value is not a string
      • getInteger

        public Integer getInteger​(String key)
        Returns the value associated with the specified key as an integer. Returns null if the key is not present.
        Parameters:
        key - the key
        Returns:
        the value
        Throws:
        ClassCastException - if the value is not a Number
      • getLong

        public Long getLong​(String key)
        Returns the value associated with the specified key as a long. Returns null if the key is not present.
        Parameters:
        key - the key
        Returns:
        the value
        Throws:
        ClassCastException - if the value is not a Number
      • getDouble

        public Double getDouble​(String key)
        Returns the value associated with the specified key as a double. Returns null if the key is not present.
        Parameters:
        key - the key
        Returns:
        the value
        Throws:
        ClassCastException - if the value is not a Number
      • getBoolean

        public Boolean getBoolean​(String key)
        Returns the value associated with the specified key as a boolean. Returns null if the key is not present.
        Parameters:
        key - the key
        Returns:
        the value
        Throws:
        ClassCastException - if the value is not a boolean
      • getDecimal

        public BigDecimal getDecimal​(String key)
        Returns the value associated with the specified key as a BigDecimal. Returns null if the key is not present.
        Parameters:
        key - the key
        Returns:
        the value
        Throws:
        ClassCastException - if the value is not a Number
      • getKsqlArray

        public KsqlArray getKsqlArray​(String key)
        Returns the value associated with the specified key as a KsqlArray. Returns null if the key is not present.
        Parameters:
        key - the key
        Returns:
        the value
        Throws:
        ClassCastException - if the value cannot be converted to a list
      • getKsqlObject

        public KsqlObject getKsqlObject​(String key)
        Returns the value associated with the specified key as a KsqlObject. Returns null if the key is not present.
        Parameters:
        key - the key
        Returns:
        the value
        Throws:
        ClassCastException - if the value cannot be converted to a map
      • remove

        public Object remove​(String key)
        Removes the value associated with a specified key.
        Parameters:
        key - the key
        Returns:
        the removed value, or null if the key was not present
      • put

        public KsqlObject put​(String key,
                              Integer value)
        Adds an entry for the specified key and value to the map.
        Parameters:
        key - the key
        value - the value
        Returns:
        a reference to this
      • put

        public KsqlObject put​(String key,
                              Long value)
        Adds an entry for the specified key and value to the map.
        Parameters:
        key - the key
        value - the value
        Returns:
        a reference to this
      • put

        public KsqlObject put​(String key,
                              String value)
        Adds an entry for the specified key and value to the map.
        Parameters:
        key - the key
        value - the value
        Returns:
        a reference to this
      • put

        public KsqlObject put​(String key,
                              Double value)
        Adds an entry for the specified key and value to the map.
        Parameters:
        key - the key
        value - the value
        Returns:
        a reference to this
      • put

        public KsqlObject put​(String key,
                              Boolean value)
        Adds an entry for the specified key and value to the map.
        Parameters:
        key - the key
        value - the value
        Returns:
        a reference to this
      • put

        public KsqlObject put​(String key,
                              BigDecimal value)
        Adds an entry for the specified key and value to the map.
        Parameters:
        key - the key
        value - the value
        Returns:
        a reference to this
      • put

        public KsqlObject put​(String key,
                              KsqlArray value)
        Adds an entry for the specified key and value to the map.
        Parameters:
        key - the key
        value - the value
        Returns:
        a reference to this
      • put

        public KsqlObject put​(String key,
                              KsqlObject value)
        Adds an entry for the specified key and value to the map.
        Parameters:
        key - the key
        value - the value
        Returns:
        a reference to this
      • put

        public KsqlObject put​(String key,
                              Object value)
        Adds an entry for the specified key and value to the map.
        Parameters:
        key - the key
        value - the value
        Returns:
        a reference to this
      • putNull

        public KsqlObject putNull​(String key)
        Adds an entry for the specified key with null value to the map.
        Parameters:
        key - the key
        Returns:
        a reference to this
      • mergeIn

        public KsqlObject mergeIn​(KsqlObject other)
        Adds entries from the specified KsqlObject into this instance.
        Parameters:
        other - the entries to add
        Returns:
        a reference to this
      • copy

        public KsqlObject copy()
        Returns a copy of this.
        Returns:
        the copy
      • toJsonString

        public String toJsonString()
        Returns a JSON string representing the entries in the map.
        Returns:
        the JSON string
      • toString

        public String toString()
        Returns a JSON string representing the entries in the map. Same as toJsonString().
        Overrides:
        toString in class Object
        Returns:
        the JSON string
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object