com.holonplatform.core.internal

## Class DefaultParameterSet

- java.lang.Object
- - com.holonplatform.core.internal.DefaultParameterSet

- All Implemented Interfaces:
    MutableParameterSet, ParameterSet, Serializable
  Direct Known Subclasses:
    DefaultAuthentication, DefaultSpringSecurityAuthentication

      public class DefaultParameterSet
      extends Object
      implements MutableParameterSet

  Default `ParameterSet` implementation. A `HashMap` is used to store parameters values.
  Since:
    4.5.0
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `DefaultParameterSet.AbstractBuilder<S extends ParameterSet,I extends DefaultParameterSet,B extends ParameterSet.Builder<S>>` Abstract ParameterSet builder.
    `static class` | `DefaultParameterSet.DefaultBuilder` Builder for fluent-style ParameterSet construction.

    - ### Nested classes/interfaces inherited from interface com.holonplatform.core.ParameterSet

      `ParameterSet.Builder<S extends ParameterSet>`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultParameterSet()` Construct a new ParameterSet
    `DefaultParameterSet(Map<String,Object> parameters)` Construct a new ParameterSet using given `parameters` as initial value.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addParameter(String name, Object value)` Add a parameter.
    `void` | `forEachParameter(BiConsumer<String,Object> action)` Performs the given action for each entry (name-value) of this parameter set.
    `Optional<Object>` | `getParameter(String name)` Get value of parameter named `name`, if found.
    `<T> Optional<T>` | `getParameter(String name, Class<T> type)` Get typed parameter value.
    `<T> Optional<T>` | `getParameterIf(String name, Class<T> type, Predicate<T> condition)` Get a (typed) parameter value only if parameter is present, has a not `null` value, and its value satisfies given `condition`.
    `boolean` | `hasNotNullParameter(String name)` Just like `ParameterSet.hasParameter(String)`, check if parameter with given `name` is present, but returns `true` only if parameter has a not `null` value.
    `boolean` | `hasParameter(String name)` Check if parameter is present using parameter `name`.
    `boolean` | `hasParameters()` Check if some parameter is present
    `boolean` | `hasParameterValue(String name, Object value)` Checks if a parameter with given `name` is present and its value is equal to given `value`.
    `void` | `removeParameter(String name)` Remove parameter named `name`, if exists.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface com.holonplatform.core.ParameterSet

      `builder, empty, getParameter, getParameter, getParameter, getParameterIf, hasNotNullParameter, hasParameter, hasParameterValue`

- - ### Constructor Detail

    - #### DefaultParameterSet

          public DefaultParameterSet()

      Construct a new ParameterSet

    - #### DefaultParameterSet

          public DefaultParameterSet(Map<String,Object> parameters)

      Construct a new ParameterSet using given `parameters` as initial value.
      Parameters:
        `parameters` - Initial parameters

  - ### Method Detail

    - #### hasParameters

          public boolean hasParameters()

      Description copied from interface: `ParameterSet`
      Check if some parameter is present
      Specified by:
        `hasParameters` in interface `ParameterSet`
      Returns:
        `true` if some parameter is present, `false` if set is empty.

    - #### hasParameter

          public boolean hasParameter(String name)

      Description copied from interface: `ParameterSet`
      Check if parameter is present using parameter `name`. `null` parameter values are allowed, so if a parameter is present it doesn't means that it has a value.
      Specified by:
        `hasParameter` in interface `ParameterSet`
      Parameters:
        `name` - Parameter name
      Returns:
        `true` if parameter is present, `false` otherwise

    - #### hasNotNullParameter

          public boolean hasNotNullParameter(String name)

      Description copied from interface: `ParameterSet`
      Just like `ParameterSet.hasParameter(String)`, check if parameter with given `name` is present, but returns `true` only if parameter has a not `null` value.
      Specified by:
        `hasNotNullParameter` in interface `ParameterSet`
      Parameters:
        `name` - Parameter name
      Returns:
        `true` if parameter is present and its value is not null, `false` otherwise

    - #### getParameter

          public Optional<Object> getParameter(String name)

      Description copied from interface: `ParameterSet`
      Get value of parameter named `name`, if found.
      Specified by:
        `getParameter` in interface `ParameterSet`
      Parameters:
        `name` - Parameter name (not null)
      Returns:
        Parameter value, or an empty Optional if parameter name is not present

    - #### getParameter

          public <T> Optional<T> getParameter(String name,
                                              Class<T> type)

      Description copied from interface: `ParameterSet`
      Get typed parameter value. An unchecked cast to required type will be performed.
      Specified by:
        `getParameter` in interface `ParameterSet`
      Type Parameters:
        `T` - Parameter value type
      Parameters:
        `name` - Parameter name (not null)
        `type` - Expected value type
      Returns:
        Parameter value, or an empty Optional if parameter is not present

    - #### getParameterIf

          public <T> Optional<T> getParameterIf(String name,
                                                Class<T> type,
                                                Predicate<T> condition)

      Description copied from interface: `ParameterSet`
      Get a (typed) parameter value only if parameter is present, has a not `null` value, and its value satisfies given `condition`.
      Specified by:
        `getParameterIf` in interface `ParameterSet`
      Type Parameters:
        `T` - Parameter value type
      Parameters:
        `name` - Parameter name (not null)
        `type` - Expected value type
        `condition` - Condition to check (not null)
      Returns:
        Parameter value, or an empty Optional if parameter is not present, or has not a value or its value does not satisfy given `condition`

    - #### hasParameterValue

          public boolean hasParameterValue(String name,
                                           Object value)

      Description copied from interface: `ParameterSet`
      Checks if a parameter with given `name` is present and its value is equal to given `value`.
      Specified by:
        `hasParameterValue` in interface `ParameterSet`
      Parameters:
        `name` - Parameter name (not null)
        `value` - Parameter value to check (may be null)
      Returns:
        `true` if a parameter with given `name` is present and its value is equal to given `value`, `false` if a parameter with given `name` is not present or if its value it's not equal to the expected value

    - #### forEachParameter

          public void forEachParameter(BiConsumer<String,Object> action)

      Description copied from interface: `ParameterSet`
      Performs the given action for each entry (name-value) of this parameter set.
      Specified by:
        `forEachParameter` in interface `ParameterSet`
      Parameters:
        `action` - Action to perform (not null)

    - #### addParameter

          public void addParameter(String name,
                                   Object value)

      Description copied from interface: `MutableParameterSet`
      Add a parameter. If a parameter with given `name` already exists, its value will be replaced by the new `value`.
      Specified by:
        `addParameter` in interface `MutableParameterSet`
      Parameters:
        `name` - Parameter name (not null)
        `value` - Parameter value

    - #### removeParameter

          public void removeParameter(String name)

      Description copied from interface: `MutableParameterSet`
      Remove parameter named `name`, if exists.
      Specified by:
        `removeParameter` in interface `MutableParameterSet`
      Parameters:
        `name` - Parameter name (not null)

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2019 The Holon Platform. All rights reserved.