@PublicEvolving public class Params extends Object implements Serializable, Cloneable
Constructor and Description |
---|
Params() |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all of the params.
|
Params |
clone()
Creates and returns a deep clone of this Params.
|
<V> boolean |
contains(ParamInfo<V> info)
Check whether this params has a value set for the given
info . |
static Params |
fromJson(String json)
Factory method for constructing params.
|
<V> V |
get(ParamInfo<V> info)
Returns the value of the specific parameter, or default value defined in the
info if
this Params doesn't have a value set for the parameter. |
boolean |
isEmpty()
Returns true if this params contains no mappings.
|
void |
loadJson(String json)
Restores the parameters from the given json.
|
Params |
merge(Params otherParams)
Merge other params into this.
|
<V> void |
remove(ParamInfo<V> info)
Removes the specific parameter from this Params.
|
<V> Params |
set(ParamInfo<V> info,
V value)
Set the value of the specific parameter.
|
int |
size()
Return the number of params.
|
String |
toJson()
Returns a json containing all parameters in this Params.
|
public int size()
public void clear()
public boolean isEmpty()
public <V> V get(ParamInfo<V> info)
info
if
this Params doesn't have a value set for the parameter. An exception will be thrown in the
following cases because no value could be found for the specified parameter.
V
- the type of the specific parameterinfo
- the info of the specific parameter, usually with default valueinfo
if
this Params doesn't contain the parameterIllegalArgumentException
- if no value can be found for specified parameterpublic <V> Params set(ParamInfo<V> info, V value)
V
- the type of the specific parameter.info
- the info of the specific parameter to set.value
- the value to be set to the specific parameter.RuntimeException
- if the info
has a validator and the value
is
evaluated as illegal by the validatorpublic <V> void remove(ParamInfo<V> info)
V
- the type of the specific parameterinfo
- the info of the specific parameter to removepublic <V> boolean contains(ParamInfo<V> info)
info
.info
, false otherwise.public String toJson()
public void loadJson(String json)
json
- the json String to restore frompublic static Params fromJson(String json)
json
- the json string to loadParams
loaded from the json string.public Params merge(Params otherParams)
otherParams
- other paramsCopyright © 2014–2020 The Apache Software Foundation. All rights reserved.