Class Parameters

All Implemented Interfaces:
Serializable, Cloneable, Map<String,Object>

public class Parameters extends AnyValueMap
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:
  • Constructor Details

    • Parameters

      public Parameters()
      Creates a new instance of the map.
    • Parameters

      public Parameters(Map<?,?> map)
      Creates a new instance of the map and assigns its value.
      Parameters:
      map - (optional) values to initialize this map.
  • Method Details

    • get

      public Object get(String key)
      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 class AnyValueMap
      Parameters:
      key - a key of the element to get.
      Returns:
      the value of the map element.
    • put

      public Object put(String key, Object value)
      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.

      Specified by:
      put in interface Map<String,Object>
      Overrides:
      put in class HashMap<String,Object>
      Parameters:
      key - a key of the element to put.
      value - a new value for map element.
    • getAsNullableParameters

      public Parameters getAsNullableParameters(String key)
      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

      public Parameters getAsParameters(String key)
      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

      public Parameters getAsParametersWithDefault(String key, Parameters defaultValue)
      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

      public boolean containsKey(Object key)
      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 interface Map<String,Object>
      Overrides:
      containsKey in class HashMap<String,Object>
      Parameters:
      key - a key to be checked
      Returns:
      true if this map contains the key or false otherwise.
    • override

      public Parameters override(Parameters parameters)
      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

      public Parameters override(Parameters parameters, boolean recursive)
      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

      public Parameters setDefaults(Parameters defaultParameters)
      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

      public Parameters setDefaults(Parameters defaultParameters, boolean recursive)
      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

      public void assignTo(Object value)
      Assigns (copies over) properties from the specified value to this map.
      Parameters:
      value - value whose properties shall be copied over.
    • pick

      public Parameters pick(String... paths)
      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

      public Parameters omit(String... paths)
      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

      public String toJson() throws com.fasterxml.jackson.core.JsonProcessingException
      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

      public static Parameters fromValue(Object value)
      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

      public static Parameters fromTuples(Object... tuples)
      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

      public static Parameters mergeParams(Parameters... parameters)
      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

      public static Parameters fromJson(String json)
      Creates new Parameters from JSON object.
      Parameters:
      json - a JSON string containing parameters.
      Returns:
      a new Parameters object.
      See Also:
    • fromConfig

      public static Parameters fromConfig(ConfigParams config)
      Creates new Parameters from ConfigMap object.
      Parameters:
      config - a ConfigParams that contain parameters.
      Returns:
      a new Parameters object.
      See Also: