Package org.apache.any23.configuration

## Class Settings

- java.lang.Object
- - java.util.AbstractCollection<E>
  - - java.util.AbstractSet<Setting<?>>
    - - org.apache.any23.configuration.Settings

- All Implemented Interfaces:
    `Iterable<Setting<?>>`, `Collection<Setting<?>>`, `Set<Setting<?>>`

      public final class Settings
      extends AbstractSet<Setting<?>>

  This class represents an immutable `Set` of `Setting` objects, with the additional property that no two settings having the same `identifier` can be simultaneously present in a `Settings` object.
  Author:
    Hans Brende (hansbrende@apache.org)

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `boolean` | `contains​(Object o)` |
    `Optional<Setting<?>>` | `find​(String identifier)` |
    `<S extends Setting<?>> Optional<S>` | `find​(S setting)` | This method is semantically equivalent to:
    `<E> E` | `get​(Setting<E> defaultSetting)` | This method is semantically equivalent to:
    `Iterator<Setting<?>>` | `iterator()` |
    `static Settings` | `of()` | Returns an empty `Settings` object.
    `static Settings` | `of​(Collection<? extends Setting<?>> c)` |
    `static Settings` | `of​(Setting<?> s)` | Returns a singleton `Settings` object, containing only the supplied Setting.
    `static Settings` | `of​(Setting<?>... settings)` |
    `int` | `size()` |

    - ### Methods inherited from class java.util.AbstractSet

      `equals, hashCode, removeAll`

    - ### Methods inherited from class java.util.AbstractCollection

      `add, addAll, clear, containsAll, isEmpty, remove, retainAll, toArray, toArray, toString`

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.util.Collection

      `parallelStream, removeIf, stream, toArray`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach`

    - ### Methods inherited from interface java.util.Set

      `add, addAll, clear, containsAll, isEmpty, remove, retainAll, spliterator, toArray, toArray`

- - ### Method Detail

    - #### find

          public Optional<Setting<?>> find​(String identifier)

      Parameters:
        `identifier` - the identifier of the setting to find
      Returns:
        the setting with the identifier supplied, if present

    - #### find

          public <S extends Setting<?>> Optional<S> find​(S setting)

      This method is semantically equivalent to:

           find(setting.getIdentifier()).flatMap(s -> s.as(setting))

      Type Parameters:
        `S` - generic setting type
      Parameters:
        `setting` - a setting key
      Returns:
        the setting with the same setting key as the supplied setting, if present.

    - #### get

          public <E> E get​(Setting<E> defaultSetting)

      This method is semantically equivalent to:

           find(defaultSetting).orElse(defaultSetting).getValue()

      Type Parameters:
        `E` - generic setting type
      Parameters:
        `defaultSetting` - a default key for which to obtain a value set
      Returns:
        the value set for `defaultSetting`'s key, if present. Otherwise, returns `defaultSetting`'s value.

    - #### contains

          public boolean contains​(Object o)

      Specified by:
        `contains` in interface `Collection<Setting<?>>`
      Specified by:
        `contains` in interface `Set<Setting<?>>`
      Overrides:
        `contains` in class `AbstractCollection<Setting<?>>`

    - #### size

          public int size()

      Specified by:
        `size` in interface `Collection<Setting<?>>`
      Specified by:
        `size` in interface `Set<Setting<?>>`
      Specified by:
        `size` in class `AbstractCollection<Setting<?>>`

    - #### iterator

          public Iterator<Setting<?>> iterator()

      Specified by:
        `iterator` in interface `Collection<Setting<?>>`
      Specified by:
        `iterator` in interface `Iterable<Setting<?>>`
      Specified by:
        `iterator` in interface `Set<Setting<?>>`
      Specified by:
        `iterator` in class `AbstractCollection<Setting<?>>`

    - #### of

          public static Settings of()

      Returns an empty `Settings` object.
      Returns:
        an empty `Settings` object

    - #### of

          public static Settings of​(Setting<?> s)

      Returns a singleton `Settings` object, containing only the supplied Setting.
      Parameters:
        `s` - one `Setting`
      Returns:
        a `Settings` object containing the supplied Setting.

    - #### of

          public static Settings of​(Setting<?>... settings)

      Parameters:
        `settings` - one or more `Setting`'s
      Returns:
        a `Settings` object containing the supplied settings. For any two settings having the same key, the first will be overwritten by the second.
      Throws:
        `IllegalArgumentException` - if any two settings have the same identifier

    - #### of

          public static Settings of​(Collection<? extends Setting<?>> c)

      Parameters:
        `c` - a populated `Collection` of `Setting`'s
      Returns:
        a `Settings` object containing the supplied settings.
      Throws:
        `IllegalArgumentException` - if any two settings have the same identifier