Package jsonvalues

Class TryArr


  • public final class TryArr
    extends Object
    Computation that parses a string into a JsArray and may either result in a MalformedJson exception or a successfully parsed array.
    • Method Detail

      • isFailure

        public boolean isFailure()
        Returns true if the parsed string is not a well-formed json array.
        Returns:
        true if the parsed string is not a well-formed json array
      • isSuccess

        public boolean isSuccess()
        Returns true if the parsed string is a well-formed json array.
        Returns:
        true if the parsed string is a well-formed json array
      • toOptional

        public Optional<JsArray> toOptional()
        Returns the computed JsArray wrapped in an optional if the parsed string is a well-formed json array, returning an empty optional otherwise.
        Returns:
        Optional.empty() if the parsed string is not a well-formed json array, or an Optional containing the computed JsArray otherwise.
      • orElse

        public JsArray orElse​(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.
        Parameters:
        other - supplier to be executed if the parsed string is not a well-formed json array
        Returns:
        a JsArray
      • orElseThrow

        public JsArray orElseThrow()
                            throws MalformedJson
        Returns the computed JsArray if the parsed string is a well-formed json array, throwing a MalformedJson otherwise.
        Returns:
        a JsArray
        Throws:
        MalformedJson - if the parsed string is not a well-formed json array