Interface CliParameter

All Known Implementing Classes:
CliParameter.Invalid, CliParameter.Valid

public sealed interface CliParameter permits CliParameter.Valid, CliParameter.Invalid
JSON-RPC method parameter, parsed from the command-line. There are two implementations: CliParameter.Valid and CliParameter.Invalid. A Valid contains an object that can be serialized to JSON via a converter/mapper like Jackson. An Invalid contains the Exception that occurred while parsing.
  • Method Details

    • source

      Return the source (pre-deserialization) JSON string
      Returns:
      source string
    • valid

      default boolean valid()
    • invalid

      default boolean invalid()
    • stream

      Stream zero or 1 valid objects.

      This allows .flatMap(CliParameter::stream) to filter invalid and unwrap valid objects.

      Returns:
      A stream of zero or one valid objects.
    • valid

      static CliParameter.Valid valid(String source, Object object)
      Create a Valid object
      Parameters:
      source - The source CLI string
      object - The resulting object
      Returns:
      a valid parameter
    • invalid

      static CliParameter.Invalid invalid(String source, Exception error)
      Create a Invalid object
      Parameters:
      source - The source CLI string
      error - The error returned from the parser
      Returns:
      a valid parameter
    • parse

      static CliParameter parse(String source, CliParameter.Parser parseFunction)
      Parse a string returning either a valid or invalid CliParameter
      Parameters:
      source - the CLI parameter string to parse
      parseFunction - a parsing function
      Returns:
      wraps either parsed, serializable object or an Exception