Package org.pipservices3.commons.run
Class Parameters
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<String,Object>
org.pipservices3.commons.data.AnyValueMap
org.pipservices3.commons.run.Parameters
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<String,
Object>
Contains map with execution parameters.
In general, this map may contain non-serializable values. And in contrast with other maps, its getters and setters support dot notation and able to access properties in the entire object graph.
This class is often use to pass execution and notification arguments, and parameterize classes before execution.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,
V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Constructor Summary
ConstructorDescriptionCreates a new instance of the map.Parameters
(Map<?, ?> map) Creates a new instance of the map and assigns its value. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Assigns (copies over) properties from the specified value to this map.boolean
containsKey
(Object key) Checks if this map contains an element with specified key.static Parameters
fromConfig
(ConfigParams config) Creates new Parameters from ConfigMap object.static Parameters
Creates new Parameters from JSON object.static Parameters
fromTuples
(Object... tuples) Creates a new Parameters object filled with provided key-value pairs called tuples.static Parameters
Creates a new Parameters object filled with key-value pairs from specified object.Gets a map element specified by its key.Converts map element into an Parameters or returns null if conversion is not possible.getAsParameters
(String key) Converts map element into an Parameters or returns empty Parameters if conversion is not possible.getAsParametersWithDefault
(String key, Parameters defaultValue) Converts map element into an Parameters or returns default value if conversion is not possible.static Parameters
mergeParams
(Parameters... parameters) Merges two or more Parameters into one.Omits selected parameters from this Parameters and returns the rest as a new Parameters object.override
(Parameters parameters) Overrides parameters with new values from specified Parameters and returns a new Parameters object.override
(Parameters parameters, boolean recursive) Overrides parameters with new values from specified Parameters and returns a new Parameters object.Picks select parameters from this Parameters and returns them as a new Parameters object.Puts a new value into map element specified by its key.setDefaults
(Parameters defaultParameters) Set default values from specified Parameters and returns a new Parameters object.setDefaults
(Parameters defaultParameters, boolean recursive) Set default values from specified Parameters and returns a new Parameters object.toJson()
Converts this map to JSON object.Methods inherited from class org.pipservices3.commons.data.AnyValueMap
append, clone, fromMaps, fromTuplesArray, getAsArray, getAsArrayWithDefault, getAsBoolean, getAsBooleanWithDefault, getAsDateTime, getAsDateTimeWithDefault, getAsDouble, getAsDoubleWithDefault, getAsDuration, getAsDurationWithDefault, getAsEnum, getAsEnumWithDefault, getAsFloat, getAsFloatWithDefault, getAsInteger, getAsIntegerWithDefault, getAsLong, getAsLongWithDefault, getAsMap, getAsMapWithDefault, getAsNullableArray, getAsNullableBoolean, getAsNullableDateTime, getAsNullableDouble, getAsNullableDuration, getAsNullableEnum, getAsNullableFloat, getAsNullableInteger, getAsNullableLong, getAsNullableMap, getAsNullableString, getAsNullableType, getAsObject, getAsObject, getAsString, getAsStringWithDefault, getAsType, getAsTypeWithDefault, getAsValue, getKeys, length, setAsObject, setAsObject, toString
Methods inherited from class java.util.HashMap
clear, compute, computeIfAbsent, computeIfPresent, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
Methods inherited from class java.util.AbstractMap
equals, hashCode
-
Constructor Details
-
Parameters
public Parameters()Creates a new instance of the map. -
Parameters
Creates a new instance of the map and assigns its value.- Parameters:
map
- (optional) values to initialize this map.
-
-
Method Details
-
get
Gets a map element specified by its key.The key can be defined using dot notation and allows to recursively access elements of elements.
- Overrides:
get
in classAnyValueMap
- Parameters:
key
- a key of the element to get.- Returns:
- the value of the map element.
-
put
Puts a new value into map element specified by its key.The key can be defined using dot notation and allows to recursively access elements of elements.
-
getAsNullableParameters
Converts map element into an Parameters or returns null if conversion is not possible.- Parameters:
key
- a key of element to get.- Returns:
- Parameters value of the element or null if conversion is not supported.
-
getAsParameters
Converts map element into an Parameters or returns empty Parameters if conversion is not possible.- Parameters:
key
- a key of element to get.- Returns:
- Parameters value of the element or empty Parameters if conversion is not supported.
-
getAsParametersWithDefault
Converts map element into an Parameters or returns default value if conversion is not possible.- Parameters:
key
- a key of element to get.defaultValue
- the default value- Returns:
- Parameters value of the element or default value if conversion is not supported.
-
containsKey
Checks if this map contains an element with specified key.The key can be defined using dot notation and allows to recursively access elements of elements.
- Specified by:
containsKey
in interfaceMap<String,
Object> - Overrides:
containsKey
in classHashMap<String,
Object> - Parameters:
key
- a key to be checked- Returns:
- true if this map contains the key or false otherwise.
-
override
Overrides parameters with new values from specified Parameters and returns a new Parameters object.- Parameters:
parameters
- Parameters with parameters to override the current values.- Returns:
- a new Parameters object.
-
override
Overrides parameters with new values from specified Parameters and returns a new Parameters object.- Parameters:
parameters
- Parameters with parameters to override the current values.recursive
- (optional) true to perform deep copy, and false for shallow copy. Default: false- Returns:
- a new Parameters object.
-
setDefaults
Set default values from specified Parameters and returns a new Parameters object.- Parameters:
defaultParameters
- Parameters with default parameter values.- Returns:
- a new Parameters object.
-
setDefaults
Set default values from specified Parameters and returns a new Parameters object.- Parameters:
defaultParameters
- Parameters with default parameter values.recursive
- (optional) true to perform deep copy, and false for shallow copy. Default: false- Returns:
- a new Parameters object.
-
assignTo
Assigns (copies over) properties from the specified value to this map.- Parameters:
value
- value whose properties shall be copied over.
-
pick
Picks select parameters from this Parameters and returns them as a new Parameters object.- Parameters:
paths
- keys to be picked and copied over to new Parameters.- Returns:
- a new Parameters object.
-
omit
Omits selected parameters from this Parameters and returns the rest as a new Parameters object.- Parameters:
paths
- keys to be omitted from copying over to new Parameters.- Returns:
- a new Parameters object.
-
toJson
Converts this map to JSON object.- Returns:
- a JSON representation of this map.
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
- when conversion fails for any reason.
-
fromValue
Creates a new Parameters object filled with key-value pairs from specified object.- Parameters:
value
- an object with key-value pairs used to initialize a new Parameters.- Returns:
- a new Parameters object.
-
fromTuples
Creates a new Parameters object filled with provided key-value pairs called tuples. Tuples parameters contain a sequence of key1, value1, key2, value2, ... pairs.- Parameters:
tuples
- the tuples to fill a new Parameters object.- Returns:
- a new Parameters object.
- See Also:
-
mergeParams
Merges two or more Parameters into one. The following Parameters override previously defined parameters.- Parameters:
parameters
- a list of Parameters objects to be merged.- Returns:
- a new Parameters object.
- See Also:
-
fromJson
Creates new Parameters from JSON object.- Parameters:
json
- a JSON string containing parameters.- Returns:
- a new Parameters object.
- See Also:
-
fromConfig
Creates new Parameters from ConfigMap object.- Parameters:
config
- a ConfigParams that contain parameters.- Returns:
- a new Parameters object.
- See Also:
-