- java.lang.Object
-
- org.shredzone.acme4j.toolbox.JSON.Value
-
- Enclosing class:
- JSON
public static final class JSON.Value extends Object
A single JSON value. This instance also coversnull
values.All return values are never
null
unless specified otherwise. For optional parameters, useoptional()
.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JSON.Array
asArray()
Returns the value asJSON.Array
.byte[]
asBinary()
Returns the value as base64 decoded byte array.boolean
asBoolean()
Returns the value as boolean.Duration
asDuration()
Returns the value asDuration
.JSON
asEncodedObject()
Returns the value as JSON object that was Base64 URL encoded.Identifier
asIdentifier()
Returns the value asIdentifier
.Instant
asInstant()
Returns the value asInstant
.int
asInt()
Returns the value as int.JSON
asObject()
Returns the value as JSON object.Problem
asProblem(URL baseUrl)
Returns the value asProblem
.Status
asStatus()
Returns the parsedStatus
.String
asString()
Returns the value asString
.URI
asURI()
Returns the value asURI
.URL
asURL()
Returns the value asURL
.boolean
equals(Object obj)
int
hashCode()
boolean
isPresent()
Checks if this value isnull
.<T> Optional<T>
map(Function<JSON.Value,T> mapper)
Returns this value as anOptional
of the desired type, for further mapping and filtering.JSON.Value
onFeature(String feature)
Returns this value.Optional<JSON.Value>
optional()
Returns this value asOptional
, for further mapping and filtering.
-
-
-
Method Detail
-
isPresent
public boolean isPresent()
Checks if this value isnull
.- Returns:
true
if this value is present,false
ifnull
.
-
optional
public Optional<JSON.Value> optional()
Returns this value asOptional
, for further mapping and filtering.- Returns:
Optional
of this value, orOptional.empty()
if this value isnull
.- See Also:
map(Function)
-
onFeature
public JSON.Value onFeature(String feature)
Returns this value. If the value wasnull
, anAcmeNotSupportedException
is thrown. This method is used for mandatory fields that are only present if a certain feature is supported by the server.- Parameters:
feature
- Feature name- Returns:
- itself
-
map
public <T> Optional<T> map(Function<JSON.Value,T> mapper)
Returns this value as anOptional
of the desired type, for further mapping and filtering.- Parameters:
mapper
- AFunction
that converts aJSON.Value
to the desired type- Returns:
Optional
of this value, orOptional.empty()
if this value isnull
.- See Also:
optional()
-
asEncodedObject
public JSON asEncodedObject()
Returns the value as JSON object that was Base64 URL encoded.- Since:
- 2.8
-
asProblem
public Problem asProblem(URL baseUrl)
Returns the value asProblem
.- Parameters:
baseUrl
- BaseURL
to resolve relative links against
-
asIdentifier
public Identifier asIdentifier()
Returns the value asIdentifier
.- Since:
- 2.3
-
asArray
public JSON.Array asArray()
Returns the value asJSON.Array
.Unlike the other getters, this method returns an empty array if the value is not set. Use
isPresent()
to find out if the value was actually set.
-
asInt
public int asInt()
Returns the value as int.
-
asBoolean
public boolean asBoolean()
Returns the value as boolean.
-
asDuration
public Duration asDuration()
Returns the value asDuration
.- Since:
- 2.3
-
asBinary
public byte[] asBinary()
Returns the value as base64 decoded byte array.
-
-