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 recordImplementation for Invalid source stringsstatic interfacestatic final recordImplementation for Valid objects -
Method Summary
Modifier and TypeMethodDescriptiondefault booleaninvalid()static CliParameter.InvalidCreate aInvalidobjectstatic CliParameterparse(String source, CliParameter.Parser parseFunction) Parse a string returning either a valid or invalidCliParametersource()Return the source (pre-deserialization) JSON stringstream()Stream zero or 1 valid objects.default booleanvalid()static CliParameter.ValidCreate aValidobject
-
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 aValidobject- Parameters:
source- The source CLI stringobject- The resulting object- Returns:
- a valid parameter
-
invalid
Create aInvalidobject- 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
-