Package org.consensusj.jsonrpc.cli
Interface CliParameter
- All Known Implementing Classes:
CliParameter.Invalid
,CliParameter.Valid
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.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final record
Implementation for Invalid source stringsstatic interface
static final record
Implementation for Valid objects -
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
invalid()
static CliParameter.Invalid
Create aInvalid
objectstatic CliParameter
parse
(String source, CliParameter.Parser parseFunction) Parse a string returning either a valid or invalidCliParameter
source()
Return the source (pre-deserialization) JSON stringstream()
Stream zero or 1 valid objects.default boolean
valid()
static CliParameter.Valid
Create aValid
object
-
Method Details
-
source
Return the source (pre-deserialization) JSON string- Returns:
- source string
-
valid
-
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
Create aValid
object- Parameters:
source
- The source CLI stringobject
- The resulting object- Returns:
- a valid parameter
-
invalid
Create aInvalid
object- Parameters:
source
- The source CLI stringerror
- The error returned from the parser- Returns:
- a valid parameter
-
parse
Parse a string returning either a valid or invalidCliParameter
- Parameters:
source
- the CLI parameter string to parseparseFunction
- a parsing function- Returns:
- wraps either parsed, serializable object or an
Exception
-