- All Superinterfaces:
Hson.Value<Hson.Struct>
- Enclosing class:
Hson
HSON Struct.
A representation of a struct, with possible child values. This is similar to JsonObject
in JSON-P.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionarrayValue
(String key) Get array value.booleanArray
(String key) Get boolean array value.booleanValue
(String key) Get a boolean value.boolean
booleanValue
(String key, boolean defaultValue) Get a boolean value with default if not defined.static Hson.Struct.Builder
builder()
A new fluent API builder to construct a HSON Struct.static Hson.Struct
create()
Create an empty struct.doubleValue
(String key) Get double value.double
doubleValue
(String key, double defaultValue) Get a double value with default if not defined (or null).Get int value.int
Get an int value with default if not defined.numberArray
(String key) Get number array value.numberValue
(String key) Get number value.numberValue
(String key, BigDecimal defaultValue) Get number value with default if not defined (or null).stringArray
(String key) Get string array value.stringValue
(String key) Get string value.stringValue
(String key, String defaultValue) Get a string value with default if not defined.structArray
(String key) Get struct array value.structValue
(String key) Get struct value.Optional
<Hson.Value<?>> Get a value.
-
Method Details
-
builder
A new fluent API builder to construct a HSON Struct.- Returns:
- a new builder
-
create
Create an empty struct.- Returns:
- new empty instance
-
value
Get a value.- Parameters:
key
- key under this struct- Returns:
- value of that key, or empty if not present; may return value that represents null
- See Also:
-
booleanValue
Get a boolean value.- Parameters:
key
- key under this struct- Returns:
- boolean value if present
- Throws:
HsonException
- in case the key exists, but is not aboolean
-
booleanValue
Get a boolean value with default if not defined.- Parameters:
key
- key under this structdefaultValue
- default value to use if the key does not exist- Returns:
- boolean value, or default value if the key does not exist
- Throws:
HsonException
- in case the key exists, but is not aHson.Type.BOOLEAN
-
structValue
Get struct value. If the value representsnull
, returns empty optional.- Parameters:
key
- key under this struct- Returns:
- struct value if present
- Throws:
HsonException
- in case the key exists, but is not aHson.Type.STRUCT
-
stringValue
Get string value.- Parameters:
key
- key under this struct- Returns:
- string value if present
- Throws:
HsonException
- in case the key exists, but is not aHson.Type.STRING
-
stringValue
Get a string value with default if not defined.- Parameters:
key
- key under this structdefaultValue
- default value to use if the key does not exist- Returns:
- string value, or default value if the key does not exist
- Throws:
HsonException
- in case the key exists, but is not aHson.Type.STRING
-
intValue
Get int value.- Parameters:
key
- key under this struct- Returns:
- int value if present, from
BigDecimal.intValue()
- Throws:
HsonException
- in case the key exists, but is not aHson.Type.NUMBER
-
intValue
Get an int value with default if not defined.- Parameters:
key
- key under this structdefaultValue
- default value to use if the key does not exist- Returns:
- int value, or default value if the key does not exist
- Throws:
HsonException
- in case the key exists, but is not aHson.Type.NUMBER
- See Also:
-
doubleValue
Get double value.- Parameters:
key
- key under this struct- Returns:
- double value if present, from
BigDecimal.doubleValue()
- Throws:
HsonException
- in case the key exists, but is not aHson.Type.NUMBER
-
doubleValue
Get a double value with default if not defined (or null).- Parameters:
key
- key under this structdefaultValue
- default value to use if the key does not exist- Returns:
- double value, or default value if the key does not exist
- Throws:
HsonException
- in case the key exists, but is not aHson.Type.NUMBER
- See Also:
-
numberValue
Get number value.- Parameters:
key
- key under this struct- Returns:
- big decimal value if present
- Throws:
HsonException
- in case the key exists, but is not aHson.Type.NUMBER
-
numberValue
Get number value with default if not defined (or null).- Parameters:
key
- key under this structdefaultValue
- default value to use if not present or null- Returns:
- big decimal value
-
stringArray
Get string array value.- Parameters:
key
- key under this struct- Returns:
- string array value, if the key exists
- Throws:
HsonException
- in case the key exists, is an array, but elements are not stringsHsonException
- in case the key exists, but is not an array
-
structArray
Get struct array value.- Parameters:
key
- key under this struct- Returns:
- struct array value, if the key exists
- Throws:
HsonException
- in case the key exists, is an array, but elements are not structsHsonException
- in case the key exists, but is not an array
-
numberArray
Get number array value.- Parameters:
key
- key under this struct- Returns:
- number array value, if the key exists
- Throws:
HsonException
- in case the key exists, is an array, but elements are not numbersHsonException
- in case the key exists, but is not an array
-
booleanArray
Get boolean array value.- Parameters:
key
- key under this struct- Returns:
- boolean array value, if the key exists
- Throws:
HsonException
- in case the key exists, is an array, but elements are not booleansHsonException
- in case the key exists, but is not an array
-
arrayValue
Get array value.- Parameters:
key
- key under this struct- Returns:
- array value, if the key exists
- Throws:
HsonException
- in case the key exists, but is not an array
-