com.holonplatform.core

## Interface ParameterSet

- All Superinterfaces:
    Serializable
  All Known Subinterfaces:
    Authentication, MutableParameterSet, PropertyConfiguration, PropertyConfiguration.PropertyConfigurationEditor, QueryConfiguration, SpringSecurityAuthentication
  All Known Implementing Classes:
    DefaultAuthentication, DefaultParameterSet, DefaultSpringSecurityAuthentication

      public interface ParameterSet
      extends Serializable

  Interface for name-value parameter sets management.

  A ParameterSet is considered immutable, so only read methods are exposed.

  Each parameter must me identified by a `String` name, unique within the set, and associated to a value of any type. `null` values are allowed.

  Since:
    4.5.0

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static interface` | `ParameterSet.Builder<S extends ParameterSet>` `ParameterSet` builder.

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `static ParameterSet.Builder<ParameterSet>` | `builder()` Builder to create a ParameterSet
    `static ParameterSet` | `empty()` Create an empty `ParameterSet`.
    `void` | `forEachParameter(BiConsumer<String,Object> action)` Performs the given action for each entry (name-value) of this parameter set.
    `default <T> Optional<T>` | `getParameter(ConfigProperty<T> property)` Get the value of the parameter which name matches given `ConfigProperty` key, if found.
    `default <T> T` | `getParameter(ConfigProperty<T> property, T defaultValue)` Get the value of the parameter which name matches given `ConfigProperty` key with default-fallback support.
    `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.
    `default <T> T` | `getParameter(String name, Class<T> type, T defaultValue)` Get typed parameter value with default-fallback support.
    `default <T> Optional<T>` | `getParameterIf(ConfigProperty<T> property, Predicate<T> condition)` Get a (typed) parameter value only if parameter is present, has a not `null` value, and its value satisfies given `condition`.
    `<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`.
    `default <T> boolean` | `hasNotNullParameter(ConfigProperty<T> property)` Just like `hasParameter(ConfigProperty)`, check if parameter with given key is present, but returns `true` only if parameter has a not `null` value.
    `boolean` | `hasNotNullParameter(String name)` Just like `hasParameter(String)`, check if parameter with given `name` is present, but returns `true` only if parameter has a not `null` value.
    `default <T> boolean` | `hasParameter(ConfigProperty<T> property)` Check if a parameter is present using given `ConfigProperty` property key.
    `boolean` | `hasParameter(String name)` Check if parameter is present using parameter `name`.
    `boolean` | `hasParameters()` Check if some parameter is present
    `default <T> boolean` | `hasParameterValue(ConfigProperty<T> property, T value)` Checks if a parameter named with given `property` key is present and its value is equal to given `value`.
    `boolean` | `hasParameterValue(String name, Object value)` Checks if a parameter with given `name` is present and its value is equal to given `value`.

- - ### Method Detail

    - #### hasParameters

          boolean hasParameters()

      Check if some parameter is present
      Returns:
        `true` if some parameter is present, `false` if set is empty.

    - #### hasParameter

          boolean hasParameter(String name)

      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.
      Parameters:
        `name` - Parameter name
      Returns:
        `true` if parameter is present, `false` otherwise

    - #### hasNotNullParameter

          boolean hasNotNullParameter(String name)

      Just like `hasParameter(String)`, check if parameter with given `name` is present, but returns `true` only if parameter has a not `null` value.
      Parameters:
        `name` - Parameter name
      Returns:
        `true` if parameter is present and its value is not null, `false` otherwise

    - #### getParameter

          Optional<Object> getParameter(String name)

      Get value of parameter named `name`, if found.
      Parameters:
        `name` - Parameter name (not null)
      Returns:
        Parameter value, or an empty Optional if parameter name is not present

    - #### getParameter

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

      Get typed parameter value. An unchecked cast to required type will be performed.
      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
      Throws:
        `TypeMismatchException` - If the actual parameter value type is not compatible with the expected type

    - #### getParameter

          default <T> T getParameter(String name,
                                     Class<T> type,
                                     T defaultValue)

      Get typed parameter value with default-fallback support. An unchecked cast to required type will be performed. If parameter value was not found, `defaultValue` is returned.
      Type Parameters:
        `T` - Parameter value type
      Parameters:
        `name` - Parameter name (not null)
        `type` - Expected value type
        `defaultValue` - Default value to return when parameter was not found
      Returns:
        Parameter value, or `defaultValue` if parameter is not present
      Throws:
        `TypeMismatchException` - If the actual parameter value type is not compatible with the expected type

    - #### getParameterIf

          <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`.
      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`
      Throws:
        `TypeMismatchException` - If the actual parameter value type is not compatible with the expected type

    - #### hasParameterValue

          boolean hasParameterValue(String name,
                                    Object value)

      Checks if a parameter with given `name` is present and its value is equal to given `value`.
      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

    - #### hasParameter

          default <T> boolean hasParameter(ConfigProperty<T> property)

      Check if a parameter is present using given `ConfigProperty` property key. `null` parameter values are allowed, so if a parameter is present it doesn't means that it has a value.
      Type Parameters:
        `T` - Parameter value type
      Parameters:
        `property` - ConfigProperty to check (not null)
      Returns:
        `true` if parameter is present, `false` otherwise

    - #### hasNotNullParameter

          default <T> boolean hasNotNullParameter(ConfigProperty<T> property)

      Just like `hasParameter(ConfigProperty)`, check if parameter with given key is present, but returns `true` only if parameter has a not `null` value.
      Type Parameters:
        `T` - Parameter value type
      Parameters:
        `property` - ConfigProperty to check (not null)
      Returns:
        `true` if parameter is present and its value is not null, `false` otherwise

    - #### hasParameterValue

          default <T> boolean hasParameterValue(ConfigProperty<T> property,
                                                T value)

      Checks if a parameter named with given `property` key is present and its value is equal to given `value`.
      Type Parameters:
        `T` - Parameter value type
      Parameters:
        `property` - Configuration property (not null)
        `value` - Parameter value to check (may be null)
      Returns:
        `true` if the property is present and its value is equal to given `value`, `false` if the property is not present or if its value it's not equal to the expected value

    - #### getParameter

          default <T> Optional<T> getParameter(ConfigProperty<T> property)

      Get the value of the parameter which name matches given `ConfigProperty` key, if found.
      Type Parameters:
        `T` - Parameter value type
      Parameters:
        `property` - ConfigProperty to get (not null)
      Returns:
        Parameter value, or an empty Optional if parameter name is not present

    - #### getParameter

          default <T> T getParameter(ConfigProperty<T> property,
                                     T defaultValue)

      Get the value of the parameter which name matches given `ConfigProperty` key with default-fallback support.
      Type Parameters:
        `T` - Parameter value type
      Parameters:
        `property` - ConfigProperty to get (not null)
        `defaultValue` - Default value to return when parameter was not found
      Returns:
        Parameter value, or `defaultValue` if parameter is not present

    - #### getParameterIf

          default <T> Optional<T> getParameterIf(ConfigProperty<T> property,
                                                 Predicate<T> condition)

      Get a (typed) parameter value only if parameter is present, has a not `null` value, and its value satisfies given `condition`. This method uses a `ConfigProperty` to represent parameter name and type.
      Type Parameters:
        `T` - Parameter value type
      Parameters:
        `property` - ConfigProperty to get (not null)
        `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`

    - #### forEachParameter

          void forEachParameter(BiConsumer<String,Object> action)

      Performs the given action for each entry (name-value) of this parameter set.
      Parameters:
        `action` - Action to perform (not null)

    - #### empty

          static ParameterSet empty()

      Create an empty `ParameterSet`.
      Returns:
        A new empty `ParameterSet`

    - #### builder

          static ParameterSet.Builder<ParameterSet> builder()

      Builder to create a ParameterSet
      Returns:
        ParameterSetBuilder

Copyright © 2019 The Holon Platform. All rights reserved.