public final class Try extends Object
Modifier and Type | Method | Description |
---|---|---|
JsArray |
arrOrElse(Supplier<JsArray> other) |
Returns the computed JsArray if the parsed string is a well-formed json array, returning the JsArray
given by the supplier otherwise.
|
JsArray |
arrOrElseThrow() |
Returns the computed JsArray if the parsed string is a well-formed json array, throwing a
MalformedJson exception otherwise.
|
boolean |
isFailure() |
Returns true if the parsed string is a malformed json.
|
boolean |
isSuccess() |
Returns true if the parsed string is a well-formed json.
|
JsObj |
objOrElse(Supplier<JsObj> other) |
Returns the computed JsObj if the parsed string is a well-formed json object, returning the JsObj
given by the supplier otherwise.
|
JsObj |
objOrElseThrow() |
Returns the computed JsObj if the parsed string is a well-formed json object, throwing a
MalformedJson exception otherwise.
|
Json<?> |
orElseThrow() |
Returns the computed Json if the parsed string is a well-formed json, throwing a MalformedJson
exception otherwise.
|
Optional<Json<?>> |
toOptional() |
Returns the computed Json wrapped in an optional if the parsed string is a well-formed json,
returning an empty optional otherwise.
|
public boolean isFailure()
public boolean isSuccess()
public JsObj objOrElseThrow() throws MalformedJson
MalformedJson
- if the parsed string is not a well-formed json objectpublic JsArray arrOrElseThrow() throws MalformedJson
MalformedJson
- if the parsed string is not a well-formed json arraypublic Json<?> orElseThrow() throws MalformedJson
MalformedJson
- if the parsed string is not a well-formed jsonpublic JsArray arrOrElse(Supplier<JsArray> other)
other
- the supplierpublic JsObj objOrElse(Supplier<JsObj> other)
other
- the supplierpublic Optional<Json<?>> toOptional()
Copyright © 2019. All rights reserved.