public class NamedParamsRetriever extends ParamsRetriever
Provides a set of getter methods according to the expected parameter type (number, string, etc.) and whether the parameter is mandatory or optional:
getXXX(param_name)
for mandatory parameters, where
XXX
is the expected parameter type.
getOptXXX(param_name, default_value)
for optional
parameters, specifying a default value.
There are also generic getter methods that let you do the type conversion yourself.
If a parameter cannot be retrieved, e.g. due to a missing mandatory
parameter or bad type, a
JSONRPC2Error.INVALID_PARAMS
exception is thrown.
Example: suppose you have a method with 3 named parameters "name", "age" and "sex", where the last is optional and defaults to "female":
// Parse received request string JSONRPC2Request request = null; try { request = JSONRPC2Request.parse(jsonString); } catch (JSONRPC2ParseException e) { // handle exception... } // Create a new retriever for named parameters Map params = (Map)request.getParams(); NamedParamsRetriever r = new NamedParamsRetriever(params); try { // Extract "name" string parameter String name = r.getString("name"); // Extract "age" integer parameter int age = r.getInt("age"); // Extract optional "sex" string parameter which defaults to "female" String sex = r.getOptString("sex", "female"); } catch (JSONRPC2Error e) { // A JSONRPC2Error.INVALID_PARAMS will be thrown to indicate // an unexpected parameter type or a missing mandatory parameter. // You can use it straight away to create the appropriate // JSON-RPC 2.0 error response. JSONRPC2Response response = new JSONRPC2Response(e, null); }
Constructor and Description |
---|
NamedParamsRetriever(Map<String,Object> params)
Creates a new named parameters retriever from the specified
key-value map.
|
Modifier and Type | Method and Description |
---|---|
void |
ensureParam(String name)
Throws a
JSONRPC2Error.INVALID_PARAMS exception if there is
no parameter by the specified name. |
<T> void |
ensureParam(String name,
Class<T> clazz)
Throws a
JSONRPC2Error.INVALID_PARAMS exception if there is
no parameter by the specified name, its value is null , or
its type doesn't map to the specified. |
<T> void |
ensureParam(String name,
Class<T> clazz,
boolean allowNull)
Throws a
JSONRPC2Error.INVALID_PARAMS exception if there is
no parameter by the specified name or its type doesn't map to the
specified. |
void |
ensureParameter(String name)
Deprecated.
|
<T> void |
ensureParameter(String name,
Class<T> clazz)
Deprecated.
|
<T> void |
ensureParameter(String name,
Class<T> clazz,
boolean allowNull)
Deprecated.
|
void |
ensureParameters(String[] mandatoryNames)
Deprecated.
|
void |
ensureParameters(String[] mandatoryNames,
String[] optionalNames)
Deprecated.
|
void |
ensureParams(String[] mandatoryNames)
Throws a
JSONRPC2Error.INVALID_PARAMS if the specified
names aren't present in the parameters, or names outside the
specified are contained. |
void |
ensureParams(String[] mandatoryNames,
String[] optionalNames)
Throws a
JSONRPC2Error.INVALID_PARAMS if the specified
mandatory names aren't contained in the parameters, or names outside
the specified mandatory and optional are present. |
Object |
get(String name)
Retrieves the specified parameter which can be of any type.
|
<T> T |
get(String name,
Class<T> clazz)
Retrieves the specified parameter which must map to the provided
class (use the appropriate wrapper class for primitive types).
|
<T> T |
get(String name,
Class<T> clazz,
boolean allowNull)
Retrieves the specified parameter which must map to the provided
class (use the appropriate wrapper class for primitive types).
|
boolean |
getBoolean(String name)
Retrieves the specified boolean (maps from JSON true/false)
parameter.
|
double |
getDouble(String name)
Retrieves the specified numeric parameter as a
double . |
<T extends Enum<T>> |
getEnum(String name,
Class<T> enumClass)
Retrieves the specified enumerated parameter (from a JSON string
that has a predefined set of possible values).
|
<T extends Enum<T>> |
getEnum(String name,
Class<T> enumClass,
boolean ignoreCase)
Retrieves the specified enumerated parameter (from a JSON string
that has a predefined set of possible values), allowing for a case
insensitive match.
|
String |
getEnumString(String name,
String[] enumStrings)
Retrieves the specified enumerated string parameter.
|
String |
getEnumString(String name,
String[] enumStrings,
boolean ignoreCase)
Retrieves the specified enumerated string parameter, allowing for a
case insenstive match.
|
float |
getFloat(String name)
Retrieves the specified numeric parameter as a
float . |
int |
getInt(String name)
Retrieves the specified numeric parameter as an
int . |
List<Object> |
getList(String name)
Retrieves the specified list (maps from JSON array) parameter.
|
List<Object> |
getList(String name,
boolean allowNull)
Retrieves the specified list (maps from JSON array) parameter.
|
long |
getLong(String name)
Retrieves the specified numeric parameter as a
long . |
Map<String,Object> |
getMap(String name)
Retrieves the specified map (maps from JSON object) parameter.
|
Map<String,Object> |
getMap(String name,
boolean allowNull)
Retrieves the specified map (maps from JSON object) parameter.
|
String[] |
getNames()
Returns the names of all available parameters.
|
<T> T |
getOpt(String name,
Class<T> clazz,
boolean allowNull,
T defaultValue)
Retrieves the specified optional parameter which must map to the
provided class (use the appropriate wrapper class for primitive
types).
|
<T> T |
getOpt(String name,
Class<T> clazz,
T defaultValue)
Retrieves the specified optional parameter which must map to the
provided class (use the appropriate wrapper class for primitive
types).
|
boolean |
getOptBoolean(String name,
boolean defaultValue)
Retrieves the specified optional boolean (maps from JSON true/false)
parameter.
|
double |
getOptDouble(String name,
double defaultValue)
Retrieves the specified optional numeric parameter as a
double . |
<T extends Enum<T>> |
getOptEnum(String name,
Class<T> enumClass,
T defaultValue)
Retrieves the specified optional enumerated parameter (from a JSON
string that has a predefined set of possible values).
|
<T extends Enum<T>> |
getOptEnum(String name,
Class<T> enumClass,
T defaultValue,
boolean ignoreCase)
Retrieves the specified optional enumerated parameter (from a JSON
string that has a predefined set of possible values), allowing for
a case insenstive match.
|
String |
getOptEnumString(String name,
String[] enumStrings,
String defaultValue)
Retrieves the specified optional enumerated string parameter.
|
String |
getOptEnumString(String name,
String[] enumStrings,
String defaultValue,
boolean ignoreCase)
Retrieves the specified optional enumerated string parameter,
allowing for a case insenstive match.
|
float |
getOptFloat(String name,
float defaultValue)
Retrieves the specified optional numeric parameter as a
float . |
int |
getOptInt(String name,
int defaultValue)
Retrieves the specified optional numeric parameter as an
int . |
List<Object> |
getOptList(String name,
boolean allowNull,
List<Object> defaultValue)
Retrieves the specified optional list (maps from JSON array)
parameter.
|
List<Object> |
getOptList(String name,
List<Object> defaultValue)
Retrieves the specified optional list (maps from JSON array)
parameter.
|
long |
getOptLong(String name,
long defaultValue)
Retrieves the specified optional numeric parameter as a
long . |
Map<String,Object> |
getOptMap(String name,
boolean allowNull,
Map<String,Object> defaultValue)
Retrieves the specified optional map (maps from JSON object)
parameter.
|
Map<String,Object> |
getOptMap(String name,
Map<String,Object> defaultValue)
Retrieves the specified optional map (maps from JSON object)
parameter.
|
String |
getOptString(String name,
boolean allowNull,
String defaultValue)
Retrieves the specified optional string parameter.
|
String |
getOptString(String name,
String defaultValue)
Retrieves the specified optional string parameter.
|
String[] |
getOptStringArray(String name,
boolean allowNull,
String[] defaultValue)
Retrieves the specified optional string array (maps from JSON array
of strings) parameter.
|
String[] |
getOptStringArray(String name,
String[] defaultValue)
Retrieves the specified optional string array (maps from JSON array
of strings) parameter.
|
Map<String,Object> |
getParams()
Gets the named parameters for this retriever.
|
String |
getString(String name)
Retrieves the specified string parameter.
|
String |
getString(String name,
boolean allowNull)
Retrieves the specified string parameter.
|
String[] |
getStringArray(String name)
Retrieves the specified string array (maps from JSON array of
strings) parameter.
|
String[] |
getStringArray(String name,
boolean allowNull)
Retrieves the specified string array (maps from JSON array of
strings) parameter.
|
boolean |
hasParam(String name)
Returns
true if a parameter by the specified name exists,
else false . |
boolean |
hasParameter(String name)
Deprecated.
|
boolean |
hasParameters(String[] names)
Deprecated.
|
boolean |
hasParameters(String[] mandatoryNames,
String[] optionalNames)
Deprecated.
|
boolean |
hasParams(String[] names)
Returns
true if the parameters by the specified names exist,
else false . |
boolean |
hasParams(String[] mandatoryNames,
String[] optionalNames)
Returns
true if the parameters by the specified mandatory
names exist, false if any mandatory name is missing or a
name outside the mandatory and optional is present. |
int |
size()
Returns the parameter count.
|
getEnumStringMatch, getEnumStringMatch
public NamedParamsRetriever(Map<String,Object> params)
params
- The named parameters map. Must not be null
.public Map<String,Object> getParams()
public int size()
ParamsRetriever
size
in class ParamsRetriever
public boolean hasParam(String name)
true
if a parameter by the specified name exists,
else false
.name
- The parameter name.true
if the parameter exists, else false
.@Deprecated public boolean hasParameter(String name)
hasParam(java.lang.String)
public boolean hasParams(String[] names)
true
if the parameters by the specified names exist,
else false
.names
- The parameter names. Must not be null
.true
if the parameters exist, else false
.@Deprecated public boolean hasParameters(String[] names)
hasParams(String[])
public boolean hasParams(String[] mandatoryNames, String[] optionalNames)
true
if the parameters by the specified mandatory
names exist, false
if any mandatory name is missing or a
name outside the mandatory and optional is present.mandatoryNames
- The expected mandatory parameter names. Must
not be null
.optionalNames
- The expected optional parameter names,
empty array or null
if none.true
if the specified mandatory names and only any
of the optional are present, else false
.@Deprecated public boolean hasParameters(String[] mandatoryNames, String[] optionalNames)
hasParams(String[], String[])
public String[] getNames()
public void ensureParams(String[] mandatoryNames) throws JSONRPC2Error
JSONRPC2Error.INVALID_PARAMS
if the specified
names aren't present in the parameters, or names outside the
specified are contained.
You may use this method to a fire a proper JSON-RPC 2.0 error on a missing or unexpected mandatory parameter name.
mandatoryNames
- The expected parameter names. Must not be
null
.JSONRPC2Error
- On a missing parameter name or names outside
the specified
(JSONRPC2Error.INVALID_PARAMS
).@Deprecated public void ensureParameters(String[] mandatoryNames) throws JSONRPC2Error
JSONRPC2Error
ensureParams(String[])
public void ensureParams(String[] mandatoryNames, String[] optionalNames) throws JSONRPC2Error
JSONRPC2Error.INVALID_PARAMS
if the specified
mandatory names aren't contained in the parameters, or names outside
the specified mandatory and optional are present.
You may use this method to a fire a proper JSON-RPC 2.0 error on a missing or unexpected mandatory parameter name.
mandatoryNames
- The expected mandatory parameter names. Must
not be null
.optionalNames
- The expected optional parameter names,
empty array or null
if none.JSONRPC2Error
- On a missing mandatory parameter name or names
outside the specified mandatory and optional
(JSONRPC2Error.INVALID_PARAMS
).@Deprecated public void ensureParameters(String[] mandatoryNames, String[] optionalNames) throws JSONRPC2Error
JSONRPC2Error
ensureParams(String[], String[])
public void ensureParam(String name) throws JSONRPC2Error
JSONRPC2Error.INVALID_PARAMS
exception if there is
no parameter by the specified name.
You may use this method to fire the proper JSON-RPC 2.0 error on a missing mandatory parameter.
name
- The parameter name.JSONRPC2Error
- On a missing parameter
(JSONRPC2Error.INVALID_PARAMS
).@Deprecated public void ensureParameter(String name) throws JSONRPC2Error
JSONRPC2Error
ensureParam(String)
public <T> void ensureParam(String name, Class<T> clazz) throws JSONRPC2Error
JSONRPC2Error.INVALID_PARAMS
exception if there is
no parameter by the specified name, its value is null
, or
its type doesn't map to the specified.
You may use this method to fire the proper JSON-RPC 2.0 error on a missing or badly-typed mandatory parameter.
name
- The parameter name.clazz
- The corresponding Java class that the parameter should
map to (any one of the return types of the
getXXX()
getter methods. Set to
Object.class
to allow any type. Must not be
null
.JSONRPC2Error
- On a missing parameter, null
value or
bad type (JSONRPC2Error.INVALID_PARAMS
).@Deprecated public <T> void ensureParameter(String name, Class<T> clazz) throws JSONRPC2Error
JSONRPC2Error
ensureParam(String, Class)
public <T> void ensureParam(String name, Class<T> clazz, boolean allowNull) throws JSONRPC2Error
JSONRPC2Error.INVALID_PARAMS
exception if there is
no parameter by the specified name or its type doesn't map to the
specified.
You may use this method to fire the proper JSON-RPC 2.0 error on a missing or badly-typed mandatory parameter.
name
- The parameter name.clazz
- The corresponding Java class that the parameter
should map to (any one of the return types of the
getXXX()
getter methods. Set to
Object.class
to allow any type. Must not be
null
.allowNull
- If true
allows a null
parameter
value.JSONRPC2Error
- On a missing parameter or bad type
(JSONRPC2Error.INVALID_PARAMS
).@Deprecated public <T> void ensureParameter(String name, Class<T> clazz, boolean allowNull) throws JSONRPC2Error
JSONRPC2Error
ensureParam(String, Class, boolean)
public Object get(String name) throws JSONRPC2Error
get*
methods.name
- The parameter name.JSONRPC2Error
- On a missing parameter
(JSONRPC2Error.INVALID_PARAMS
).public <T> T get(String name, Class<T> clazz) throws JSONRPC2Error
name
- The parameter name.clazz
- The corresponding Java class that the parameter should
map to (any one of the return types of the
getXXX()
getter methods. Set to
Object.class
to allow any type. Must not be
null
.JSONRPC2Error
- On a missing parameter, null
value or
bad type (JSONRPC2Error.INVALID_PARAMS
).public <T> T get(String name, Class<T> clazz, boolean allowNull) throws JSONRPC2Error
name
- The parameter name.clazz
- The corresponding Java class that the parameter
should map to (any one of the return types of the
getXXX()
getter methods. Set to
Object.class
to allow any type. Must not be
null
.allowNull
- If true
allows a null
parameter
value.JSONRPC2Error
- On a missing parameter or bad type
(JSONRPC2Error.INVALID_PARAMS
).public <T> T getOpt(String name, Class<T> clazz, T defaultValue) throws JSONRPC2Error
name
- The parameter name.clazz
- The corresponding Java class that the parameter
should map to (any one of the return types of
the getXXX()
getter methods. Set to
Object.class
to allow any type. Must not
be null
.defaultValue
- The default return value if the parameter
doesn't exist. May be null
.JSONRPC2Error
- On a bad parameter type or null
value
(JSONRPC2Error.INVALID_PARAMS
).public <T> T getOpt(String name, Class<T> clazz, boolean allowNull, T defaultValue) throws JSONRPC2Error
name
- The parameter name.clazz
- The corresponding Java class that the parameter
should map to (any one of the return types of
the getXXX()
getter methods. Set to
Object.class
to allow any type. Must not
be null
.allowNull
- If true
allows a null
parameter
value.defaultValue
- The default return value if the parameter
doesn't exist. May be null
.JSONRPC2Error
- On a bad parameter type
(JSONRPC2Error.INVALID_PARAMS
).public String getString(String name) throws JSONRPC2Error
name
- The parameter name.JSONRPC2Error
- On a missing parameter, bad type or
null
value
(JSONRPC2Error.INVALID_PARAMS
).public String getString(String name, boolean allowNull) throws JSONRPC2Error
name
- The parameter name.allowNull
- If true
allows a null
value.JSONRPC2Error
- On a missing parameter or bad type
(JSONRPC2Error.INVALID_PARAMS
).public String getOptString(String name, String defaultValue) throws JSONRPC2Error
name
- The parameter name.defaultValue
- The default return value if the parameter
doesn't exist. May be null
.JSONRPC2Error
- On a bad type or null
value
(JSONRPC2Error.INVALID_PARAMS
).public String getOptString(String name, boolean allowNull, String defaultValue) throws JSONRPC2Error
name
- The parameter name.allowNull
- If true
allows a null
value.defaultValue
- The default return value if the parameter
doesn't exist. May be null
.JSONRPC2Error
- On a bad type (JSONRPC2Error.INVALID_PARAMS
).public String getEnumString(String name, String[] enumStrings) throws JSONRPC2Error
name
- The parameter name.enumStrings
- The acceptable string values. Must not be
null
.JSONRPC2Error
- On a missing parameter, bad type or
bad enumeration value
(JSONRPC2Error.INVALID_PARAMS
).public String getEnumString(String name, String[] enumStrings, boolean ignoreCase) throws JSONRPC2Error
name
- The parameter name.enumStrings
- The acceptable string values. Must not be
null
.ignoreCase
- true
for a case insensitive match.JSONRPC2Error
- On a missing parameter, bad type or
bad enumeration value
(JSONRPC2Error.INVALID_PARAMS
).public String getOptEnumString(String name, String[] enumStrings, String defaultValue) throws JSONRPC2Error
name
- The parameter name.enumStrings
- The acceptable string values. Must not be
null
.defaultValue
- The default return value if the parameter
doesn't exist. May be null
.JSONRPC2Error
- On a bad type or bad enumeration value
(JSONRPC2Error.INVALID_PARAMS
).public String getOptEnumString(String name, String[] enumStrings, String defaultValue, boolean ignoreCase) throws JSONRPC2Error
name
- The parameter name.enumStrings
- The acceptable string values. Must not be
null
.defaultValue
- The default return value if the parameter
doesn't exist. May be null
.ignoreCase
- true
for a case insensitive match.JSONRPC2Error
- On a bad type or bad enumeration value
(JSONRPC2Error.INVALID_PARAMS
).public <T extends Enum<T>> T getEnum(String name, Class<T> enumClass) throws JSONRPC2Error
name
- The parameter name.enumClass
- An enumeration type with constant names
representing the acceptable string values. Must not
be null
.JSONRPC2Error
- On a missing parameter, bad type or
bad enumeration value
(JSONRPC2Error.INVALID_PARAMS
).public <T extends Enum<T>> T getEnum(String name, Class<T> enumClass, boolean ignoreCase) throws JSONRPC2Error
name
- The parameter name.enumClass
- An enumeration type with constant names
representing the acceptable string values. Must
not be null
.ignoreCase
- If true
a case insensitive match against
the acceptable constant names is performed.JSONRPC2Error
- On a missing parameter, bad type or
bad enumeration value
(JSONRPC2Error.INVALID_PARAMS
).public <T extends Enum<T>> T getOptEnum(String name, Class<T> enumClass, T defaultValue) throws JSONRPC2Error
name
- The parameter name.enumClass
- An enumeration type with constant names
representing the acceptable string values. Must
not be null
.defaultValue
- The default return value if the parameter
doesn't exist. May be null
.JSONRPC2Error
- On a bad type or bad enumeration value
(JSONRPC2Error.INVALID_PARAMS
).public <T extends Enum<T>> T getOptEnum(String name, Class<T> enumClass, T defaultValue, boolean ignoreCase) throws JSONRPC2Error
name
- The parameter name.enumClass
- An enumeration type with constant names
representing the acceptable string values. Must
not be null
.defaultValue
- The default return value if the parameter
doesn't exist. May be null
.ignoreCase
- If true
a case insensitive match against
the acceptable constant names is performed.JSONRPC2Error
- On a bad type or bad enumeration value
(JSONRPC2Error.INVALID_PARAMS
).public boolean getBoolean(String name) throws JSONRPC2Error
name
- The parameter name.boolean
.JSONRPC2Error
- On a missing parameter, bad type or
null
value
(JSONRPC2Error.INVALID_PARAMS
).public boolean getOptBoolean(String name, boolean defaultValue) throws JSONRPC2Error
name
- The parameter name.defaultValue
- The default return value if the parameter
doesn't exist.boolean
.JSONRPC2Error
- On a bad parameter type or null
value
(JSONRPC2Error.INVALID_PARAMS
).public int getInt(String name) throws JSONRPC2Error
int
.name
- The parameter name.int
.JSONRPC2Error
- On a missing parameter, bad type or
null
value
(JSONRPC2Error.INVALID_PARAMS
).public int getOptInt(String name, int defaultValue) throws JSONRPC2Error
int
. If it doesn't exist the method will return the
specified default value.name
- The parameter name.defaultValue
- The default return value if the parameter
doesn't exist.int
.JSONRPC2Error
- On a bad parameter type or null
value
(JSONRPC2Error.INVALID_PARAMS
).public long getLong(String name) throws JSONRPC2Error
long
.name
- The parameter name.long
.JSONRPC2Error
- On a missing parameter, bad type or
null
value
(JSONRPC2Error.INVALID_PARAMS
).public long getOptLong(String name, long defaultValue) throws JSONRPC2Error
long
. If it doesn't exist the method will return the
specified default value.name
- The parameter name.defaultValue
- The default return value if the parameter
doesn't exist.JSONRPC2Error
- On a bad parameter type or null
value
(JSONRPC2Error.INVALID_PARAMS
).public float getFloat(String name) throws JSONRPC2Error
float
.name
- The parameter name.float
.JSONRPC2Error
- On a missing parameter, bad type or
null
value
(JSONRPC2Error.INVALID_PARAMS
).public float getOptFloat(String name, float defaultValue) throws JSONRPC2Error
float
. If it doesn't exist the method will return the
specified default value.name
- The parameter name.defaultValue
- The default return value if the parameter
doesn't exist.float
.JSONRPC2Error
- On a bad parameter type or null
value
(JSONRPC2Error.INVALID_PARAMS
).public double getDouble(String name) throws JSONRPC2Error
double
.name
- The parameter name.double
.JSONRPC2Error
- On a missing parameter, bad type or
null
value
(JSONRPC2Error.INVALID_PARAMS
).public double getOptDouble(String name, double defaultValue) throws JSONRPC2Error
double
. If it doesn't exist the method will return the
specified default value.name
- The parameter name.defaultValue
- The default return value if the parameter
doesn't exist.double
.JSONRPC2Error
- On a bad parameter type or null
value
(JSONRPC2Error.INVALID_PARAMS
).public List<Object> getList(String name) throws JSONRPC2Error
name
- The parameter name.JSONRPC2Error
- On a missing parameter, bad type or
null
value
(JSONRPC2Error.INVALID_PARAMS
).public List<Object> getList(String name, boolean allowNull) throws JSONRPC2Error
name
- The parameter name.allowNull
- If true
allows a null
value.JSONRPC2Error
- On a missing parameter or bad type
(JSONRPC2Error.INVALID_PARAMS
).public List<Object> getOptList(String name, List<Object> defaultValue) throws JSONRPC2Error
name
- The parameter name.defaultValue
- The default return value if the parameter
doesn't exist. May be null
.JSONRPC2Error
- On a bad parameter type or null
value
(JSONRPC2Error.INVALID_PARAMS
).public List<Object> getOptList(String name, boolean allowNull, List<Object> defaultValue) throws JSONRPC2Error
name
- The parameter name.allowNull
- If true
allows a null
value.defaultValue
- The default return value if the parameter
doesn't exist. May be null
.JSONRPC2Error
- On a bad parameter type
(JSONRPC2Error.INVALID_PARAMS
).public String[] getStringArray(String name) throws JSONRPC2Error
name
- The parameter name.JSONRPC2Error
- On a missing parameter, bad type or
null
value
(JSONRPC2Error.INVALID_PARAMS
).public String[] getStringArray(String name, boolean allowNull) throws JSONRPC2Error
name
- The parameter name.allowNull
- If true
allows a null
value.JSONRPC2Error
- On a missing parameter or bad type
(JSONRPC2Error.INVALID_PARAMS
).public String[] getOptStringArray(String name, String[] defaultValue) throws JSONRPC2Error
name
- The parameter name.defaultValue
- The default return value if the parameter
doesn't exist. May be null
.JSONRPC2Error
- On a bad parameter type or null
value
(JSONRPC2Error.INVALID_PARAMS
).public String[] getOptStringArray(String name, boolean allowNull, String[] defaultValue) throws JSONRPC2Error
name
- The parameter name.allowNull
- If true
allows a null
value.defaultValue
- The default return value if the parameter
doesn't exist. May be null
.JSONRPC2Error
- On a bad parameter type
(JSONRPC2Error.INVALID_PARAMS
).public Map<String,Object> getMap(String name) throws JSONRPC2Error
name
- The parameter name.JSONRPC2Error
- On a missing parameter, bad type or
null
value
(JSONRPC2Error.INVALID_PARAMS
).public Map<String,Object> getMap(String name, boolean allowNull) throws JSONRPC2Error
name
- The parameter name.allowNull
- If true
allows a null
value.JSONRPC2Error
- On a missing parameter or bad type
(JSONRPC2Error.INVALID_PARAMS
).public Map<String,Object> getOptMap(String name, Map<String,Object> defaultValue) throws JSONRPC2Error
name
- The parameter name.defaultValue
- The default return value if the parameter
doesn't exist. May be null
.JSONRPC2Error
- On a bad parameter type or null
value
(JSONRPC2Error.INVALID_PARAMS
).public Map<String,Object> getOptMap(String name, boolean allowNull, Map<String,Object> defaultValue) throws JSONRPC2Error
name
- The parameter name.allowNull
- If true
allows a null
value.defaultValue
- The default return value if the parameter
doesn't exist. May be null
.JSONRPC2Error
- On a bad parameter type
(JSONRPC2Error.INVALID_PARAMS
).Copyright © 2015 The Transaction Company. All Rights Reserved.