Package io.confluent.ksql.api.client
Class KsqlObject
- java.lang.Object
-
- io.confluent.ksql.api.client.KsqlObject
-
public class KsqlObject extends Object
A representation of a map of string keys to values. Useful for representing a JSON object.
-
-
Constructor Summary
Constructors Constructor Description KsqlObject()
Creates an empty instance.KsqlObject(Map<String,Object> map)
Creates an instance with the specified entries.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsKey(String key)
Returns whether the map contains the specified key.KsqlObject
copy()
Returns a copy of this.boolean
equals(Object o)
Set<String>
fieldNames()
Returns the keys of the map.static KsqlObject
fromArray(List<String> keys, KsqlArray values)
Boolean
getBoolean(String key)
Returns the value associated with the specified key as a boolean.byte[]
getBytes(String key)
Returns the value associated with the specified key as a byte array.BigDecimal
getDecimal(String key)
Returns the value associated with the specified key as aBigDecimal
.Double
getDouble(String key)
Returns the value associated with the specified key as a double.Integer
getInteger(String key)
Returns the value associated with the specified key as an integer.KsqlArray
getKsqlArray(String key)
Returns the value associated with the specified key as aKsqlArray
.KsqlObject
getKsqlObject(String key)
Returns the value associated with the specified key as aKsqlObject
.Long
getLong(String key)
Returns the value associated with the specified key as a long.Map<String,Object>
getMap()
Returns the entries of the map as aMap
.String
getString(String key)
Returns the value associated with the specified key as a string.Object
getValue(String key)
Returns the value associated with the specified key as anObject
.int
hashCode()
boolean
isEmpty()
Returns whether the map is empty.Iterator<Map.Entry<String,Object>>
iterator()
Returns an iterator over the entries of the map.KsqlObject
mergeIn(KsqlObject other)
Adds entries from the specifiedKsqlObject
into this instance.KsqlObject
put(String key, byte[] value)
KsqlObject
put(String key, KsqlArray value)
Adds an entry for the specified key and value to the map.KsqlObject
put(String key, KsqlObject value)
Adds an entry for the specified key and value to the map.KsqlObject
put(String key, Boolean value)
Adds an entry for the specified key and value to the map.KsqlObject
put(String key, Double value)
Adds an entry for the specified key and value to the map.KsqlObject
put(String key, Integer value)
Adds an entry for the specified key and value to the map.KsqlObject
put(String key, Long value)
Adds an entry for the specified key and value to the map.KsqlObject
put(String key, Object value)
Adds an entry for the specified key and value to the map.KsqlObject
put(String key, String value)
Adds an entry for the specified key and value to the map.KsqlObject
put(String key, BigDecimal value)
Adds an entry for the specified key and value to the map.KsqlObject
putNull(String key)
Adds an entry for the specified key with null value to the map.Object
remove(String key)
Removes the value associated with a specified key.int
size()
Returns the size (number of entries) of the map.Stream<Map.Entry<String,Object>>
stream()
Returns entries of the map as a stream.String
toJsonString()
Returns a JSON string representing the entries in the map.String
toString()
Returns a JSON string representing the entries in the map.
-
-
-
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
-
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 aMap
.- Returns:
- the entries
-
iterator
public Iterator<Map.Entry<String,Object>> iterator()
Returns an iterator over the entries of the map.- Returns:
- the iterator
-
stream
public Stream<Map.Entry<String,Object>> stream()
Returns entries of the map as a stream.- Returns:
- the stream
-
getValue
public Object getValue(String key)
Returns the value associated with the specified key as anObject
. 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 aNumber
-
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 aNumber
-
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 aNumber
-
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 aBigDecimal
. Returns null if the key is not present.- Parameters:
key
- the key- Returns:
- the value
- Throws:
ClassCastException
- if the value is not aNumber
-
getBytes
public byte[] getBytes(String key)
Returns the value associated with the specified key as a byte array. Returns null if the key is not present.- Parameters:
key
- the key- Returns:
- the value
- Throws:
ClassCastException
- if the value is not aString
IllegalArgumentException
- if the column value is not a base64 encoded string
-
getKsqlArray
public KsqlArray getKsqlArray(String key)
Returns the value associated with the specified key as aKsqlArray
. 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 aKsqlObject
. 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 keyvalue
- 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 keyvalue
- 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 keyvalue
- 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 keyvalue
- 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 keyvalue
- 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 keyvalue
- the value- Returns:
- a reference to this
-
put
public KsqlObject put(String key, byte[] value)
-
put
public KsqlObject put(String key, KsqlArray value)
Adds an entry for the specified key and value to the map.- Parameters:
key
- the keyvalue
- 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 keyvalue
- 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 keyvalue
- 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 specifiedKsqlObject
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 astoJsonString()
.
-
fromArray
public static KsqlObject fromArray(List<String> keys, KsqlArray values)
-
-