org.appng.api.support

## Class SelectionFactory

- java.lang.Object
- - org.appng.api.support.SelectionFactory

-     public class SelectionFactory
      extends Object

  Provides factory-methods for creating `Selection`s.
  Author:
    Matthias Müller

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `SelectionFactory.Selection`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SelectionFactory()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `countHits(Iterable<Option> options, OptionOwner.HitCounter<String> counter)` Counts and sets the hits for the options based on their value.
    `void` | `countHits(OptionOwner optionOwner, OptionOwner.HitCounter<String> counter)` Counts and sets the hits for the owner's options based on their value.
    `<E extends Enum<E>> T` | `fromEnum(String id, String titleId, E[] allElements, Collection<E> selectedElements)` Builds and returns a new `OptionOwner` using the given `Enum` elements.
    `<E extends Enum<E>> T` | `fromEnum(String id, String titleId, E[] allElements, Collection<E> selectedElements, NameProvider<E> nameProvider)` Builds and returns a new `OptionOwner` using the given `Enum` elements.
    `<E extends Enum<E>> T` | `fromEnum(String id, String titleId, E[] allElements, E selectedElement)` Builds and returns a new `OptionOwner` using the given `Enum` elements.
    `<E extends Enum<E>> T` | `fromEnum(String id, String titleId, E[] allElements, E selectedElement, NameProvider<E> nameProvider)` Builds and returns a new `OptionOwner` using the given `Enum` elements.
    `<I extends Identifiable<?>> T` | `fromIdentifiable(String id, String titleId, Iterable<? extends I> allElements, Collection<? extends I> selectedElements)` Builds and returns a new `OptionOwner` using the given `Identifiable` elements.
    `<I extends Identifiable<?>> T` | `fromIdentifiable(String id, String titleId, Iterable<? extends I> allElements, Collection<? extends I> selectedElements, NameProvider<I> nameProvider)` Builds and returns a new `OptionOwner` using the given `Identifiable` elements.
    `<I extends Identifiable<?>> T` | `fromIdentifiable(String id, String titleId, Iterable<? extends I> allElements, I selectedElement)` Builds and returns a new `OptionOwner` using the given `Identifiable` elements.
    `<I extends Identifiable<?>> T` | `fromIdentifiable(String id, String titleId, Iterable<? extends I> allElements, I selectedElement, NameProvider<I> nameProvider)` Builds and returns a new `OptionOwner` using the given `Identifiable` elements.
    `<I extends Identifiable<?>> T` | `fromIdentifiable(String id, String titleId, Iterable<? extends I> allElements, OptionOwner.Selector selector)` Builds and returns a new `OptionOwner` using the given `Identifiable` elements.
    `<I extends Identifiable<?>> T` | `fromIdentifiable(String id, String titleId, Iterable<? extends I> allElements, OptionOwner.Selector selector, NameProvider<I> nameProvider)` Builds and returns a new `OptionOwner` using the given `Identifiable` elements.
    `<N extends Named<?>> T` | `fromNamed(String id, String titleId, Iterable<? extends N> allElements, Collection<? extends N> selectedElements)` Builds and returns a new `OptionOwner` using the given `Named` elements.
    `<N extends Named<?>> T` | `fromNamed(String id, String titleId, Iterable<? extends N> allElements, Collection<? extends N> selectedElements, NameProvider<N> nameProvider)` Builds and returns a new `OptionOwner` using the given `Named` elements.
    `<N extends Named<?>> T` | `fromNamed(String id, String titleId, Iterable<? extends N> allElements, N selectedElement)` Builds and returns a new `OptionOwner` using the given `Named` elements.
    `<N extends Named<?>> T` | `fromNamed(String id, String titleId, Iterable<? extends N> allElements, N selectedElement, NameProvider<N> nameProvider)` Builds and returns a new `OptionOwner` using the given `Named` elements.
    `<N extends Named<?>> T` | `fromNamed(String id, String titleId, Iterable<? extends N> allElements, OptionOwner.Selector selector)` Builds and returns a new `OptionOwner` using the given `Named` elements.
    `<N extends Named<?>> T` | `fromNamed(String id, String titleId, Iterable<? extends N> allElements, OptionOwner.Selector selector, NameProvider<N> nameProvider)` Builds and returns a new `OptionOwner` using the given `Named` elements.
    `<S> T` | `fromObjects(String id, String titleId, S[] allElements, NameProvider<S> nameProvider, S... selectedElements)` Builds and returns a new `OptionOwner` using the given `Object`s.
    `<S> T` | `fromObjects(String id, String titleId, S[] allElements, OptionOwner.Selector selector)` Builds and returns a new `OptionOwner` using the given `Object`s.
    `<S> T` | `fromObjects(String id, String titleId, S[] allElements, OptionOwner.Selector selector, NameProvider<S> nameProvider)` Builds and returns a new `OptionOwner` using the given `Object`s.
    `<S> T` | `fromObjects(String id, String titleId, S[] allElements, S... selectedElements)` Builds and returns a new `OptionOwner` using the given `Object`s.
    `SelectionFactory.Selection` | `getDateSelection(String id, String title, Date value, org.apache.commons.lang3.time.FastDateFormat dateFormat)` Creates a `SelectionFactory.Selection` of type `SelectionType.DATE` with only one `Option`.
    `SelectionFactory.Selection` | `getDateSelection(String id, String title, String value, String dateFormat)` Creates a `SelectionFactory.Selection` of type `SelectionType.DATE` with only one `Option`.
    `protected SelectionFactory.Selection` | `getOwner(String id, String title)`
    `SelectionFactory.Selection` | `getSimpleSelection(String id, String title, String value, SelectionType type)` Creates a `SelectionFactory.Selection` of the given `SelectionType` with only one `Option`.
    `SelectionFactory.Selection` | `getTextSelection(String id, String title, String value)` Creates a `SelectionFactory.Selection` of type `SelectionType.TEXT` with only one `Option`.

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SelectionFactory

          public SelectionFactory()

  - ### Method Detail

    - #### getOwner

          protected SelectionFactory.Selection getOwner(String id,
                                                        String title)

    - #### getTextSelection

          public SelectionFactory.Selection getTextSelection(String id,
                                                             String title,
                                                             String value)

      Creates a `SelectionFactory.Selection` of type `SelectionType.TEXT` with only one `Option`. This option uses the given id as its name and the given value.
      Parameters:
        `id` - the id for the `SelectionFactory.Selection` and also the name of the single `Option`
        `title` - the title for the `Section`
        `value` - the `Option`'s value
      Returns:
        a `SelectionFactory.Selection` of the given type with one `Option`

    - #### getDateSelection

          public SelectionFactory.Selection getDateSelection(String id,
                                                             String title,
                                                             String value,
                                                             String dateFormat)

      Creates a `SelectionFactory.Selection` of type `SelectionType.DATE` with only one `Option`. This option uses the given id as its name and the given value.
      Parameters:
        `id` - the id for the `SelectionFactory.Selection` and also the name of the single `Option`
        `title` - the title for the `Section`
        `value` - the `Option`'s value
        `dateFormat` - the date format pattern to be used
      Returns:
        a `SelectionFactory.Selection` of the given type with one `Option`

    - #### getDateSelection

          public SelectionFactory.Selection getDateSelection(String id,
                                                             String title,
                                                             Date value,
                                                             org.apache.commons.lang3.time.FastDateFormat dateFormat)

      Creates a `SelectionFactory.Selection` of type `SelectionType.DATE` with only one `Option`. This option uses the given id as its name and the given value which is being formatted. `FastDateFormat.getPattern()` is used for `Selection.setFormat(String)`.
      Parameters:
        `id` - the id for the `SelectionFactory.Selection` and also the name of the single `Option`
        `title` - the title for the `Section`
        `value` - the `Option`'s value as a `Date`
        `dateFormat` -
      Returns:
        a `SelectionFactory.Selection` of type `SelectionType.DATE` with one `Option`

    - #### getSimpleSelection

          public SelectionFactory.Selection getSimpleSelection(String id,
                                                               String title,
                                                               String value,
                                                               SelectionType type)

      Creates a `SelectionFactory.Selection` of the given `SelectionType` with only one `Option`. This option uses the given id as its name and the given value.
      Parameters:
        `id` - the id for the `SelectionFactory.Selection` and also the name of the single `Option`
        `title` - the title for the `Section`
        `value` - the `Option`'s value
      Returns:
        a `SelectionFactory.Selection` of the given `SelectionType` with one `Option`

    - #### fromNamed

          public <N extends Named<?>> T fromNamed(String id,
                                                  String titleId,
                                                  Iterable<? extends N> allElements,
                                                  Collection<? extends N> selectedElements,
                                                  NameProvider<N> nameProvider)

      Builds and returns a new `OptionOwner` using the given `Named` elements. For the `Option`'s id, `Identifiable.getId()` is used. If no `NameProvider` is given, `Nameable.getName()()` is used for the `Option`'s value.
      Parameters:
        `id` - the id of the `OptionOwner`
        `titleId` - the title-id of the `OptionOwner` (see `Label.getId()`).
        `allElements` - the elements to create `Option`s from
        `selectedElements` - the selected elements
        `nameProvider` - a `NameProvider` (optional)
      Returns:
        a new `OptionOwner` (actually a `Selection` or a `OptionGroup`)

    - #### fromNamed

          public <N extends Named<?>> T fromNamed(String id,
                                                  String titleId,
                                                  Iterable<? extends N> allElements,
                                                  N selectedElement,
                                                  NameProvider<N> nameProvider)

      Builds and returns a new `OptionOwner` using the given `Named` elements. For the `Option`'s id, `Identifiable.getId()` is used. If no `NameProvider` is given, `Nameable.getName()()` is used for the `Option`'s value.
      Parameters:
        `id` - the id of the `OptionOwner`
        `titleId` - the title-id of the `OptionOwner` (see `Label.getId()`).
        `allElements` - the elements to create `Option`s from
        `selectedElement` - the selected element
        `nameProvider` - a `NameProvider` (optional)
      Returns:
        a new `OptionOwner` (actually a `Selection` or a `OptionGroup`)

    - #### fromNamed

          public <N extends Named<?>> T fromNamed(String id,
                                                  String titleId,
                                                  Iterable<? extends N> allElements,
                                                  Collection<? extends N> selectedElements)

      Builds and returns a new `OptionOwner` using the given `Named` elements. For the `Option`'s id, `Identifiable.getId()` is used. `Nameable.getName()()` is used for the `Option`'s value.
      Parameters:
        `id` - the id of the `OptionOwner`
        `titleId` - the title-id of the `OptionOwner` (see `Label.getId()`).
        `allElements` - the elements to create `Option`s from
        `selectedElements` - the selected elements
      Returns:
        a new `OptionOwner` (actually a `Selection` or a `OptionGroup`)

    - #### fromNamed

          public <N extends Named<?>> T fromNamed(String id,
                                                  String titleId,
                                                  Iterable<? extends N> allElements,
                                                  N selectedElement)

      Builds and returns a new `OptionOwner` using the given `Named` elements. For the `Option`'s id, `Identifiable.getId()` is used. `Nameable.getName()()` is used for the `Option`'s value.
      Parameters:
        `id` - the id of the `OptionOwner`
        `titleId` - the title-id of the `OptionOwner` (see `Label.getId()`).
        `allElements` - the elements to create `Option`s from
        `selectedElement` - the selected element
      Returns:
        a new `OptionOwner` (actually a `Selection` or a `OptionGroup`)

    - #### fromNamed

          public <N extends Named<?>> T fromNamed(String id,
                                                  String titleId,
                                                  Iterable<? extends N> allElements,
                                                  OptionOwner.Selector selector)

      Builds and returns a new `OptionOwner` using the given `Named` elements. For the `Option`'s id, `Identifiable.getId()` is used. `Nameable.getName()()` is used for the `Option`'s value.
      Parameters:
        `id` - the id of the `OptionOwner`
        `titleId` - the title-id of the `OptionOwner` (see `Label.getId()`).
        `allElements` - the elements to create `Option`s from
        `selector` - a `OptionOwner.Selector`
      Returns:
        a new `OptionOwner` (actually a `Selection` or a `OptionGroup`)

    - #### fromNamed

          public <N extends Named<?>> T fromNamed(String id,
                                                  String titleId,
                                                  Iterable<? extends N> allElements,
                                                  OptionOwner.Selector selector,
                                                  NameProvider<N> nameProvider)

      Builds and returns a new `OptionOwner` using the given `Named` elements. For the `Option`'s id, `Identifiable.getId()` is used. If no `NameProvider` is given, `Nameable.getName()()` is used for the `Option`'s value.
      Parameters:
        `id` - the id of the `OptionOwner`
        `titleId` - the title-id of the `OptionOwner` (see `Label.getId()`).
        `allElements` - the elements to create `Option`s from
        `selector` - a `OptionOwner.Selector`
        `nameProvider` - a `NameProvider` (optional)
      Returns:
        a new `OptionOwner` (actually a `Selection` or a `OptionGroup`)

    - #### fromIdentifiable

          public <I extends Identifiable<?>> T fromIdentifiable(String id,
                                                                String titleId,
                                                                Iterable<? extends I> allElements,
                                                                Collection<? extends I> selectedElements)

      Builds and returns a new `OptionOwner` using the given `Identifiable` elements. For the `Option`'s id, `Identifiable.getId()` is used, for the value `Object.toString()`.
      Parameters:
        `id` - the id of the `OptionOwner`
        `titleId` - the title-id of the `OptionOwner` (see `Label.getId()`).
        `allElements` - the elements to create `Option`s from
        `selectedElements` - the selected elements
      Returns:
        a new `OptionOwner` (actually a `Selection` or a `OptionGroup`)

    - #### fromIdentifiable

          public <I extends Identifiable<?>> T fromIdentifiable(String id,
                                                                String titleId,
                                                                Iterable<? extends I> allElements,
                                                                I selectedElement)

      Builds and returns a new `OptionOwner` using the given `Identifiable` elements. For the `Option`'s id, `Identifiable.getId()` is used, for the value `Object.toString()`.
      Parameters:
        `id` - the id of the `OptionOwner`
        `titleId` - the title-id of the `OptionOwner` (see `Label.getId()`).
        `allElements` - the elements to create `Option`s from
        `selectedElement` - the selected element
      Returns:
        a new `OptionOwner` (actually a `Selection` or a `OptionGroup`)

    - #### fromIdentifiable

          public <I extends Identifiable<?>> T fromIdentifiable(String id,
                                                                String titleId,
                                                                Iterable<? extends I> allElements,
                                                                I selectedElement,
                                                                NameProvider<I> nameProvider)

      Builds and returns a new `OptionOwner` using the given `Identifiable` elements. For the `Option`'s id, `Identifiable.getId()` is used. If no `NameProvider` is given, `Object.toString()` is used for the `Option`'s value.
      Parameters:
        `id` - the id of the `OptionOwner`
        `titleId` - the title-id of the `OptionOwner` (see `Label.getId()`).
        `allElements` - the elements to create `Option`s from
        `selectedElement` - the selected element
        `nameProvider` - a `NameProvider` (optional)
      Returns:
        a new `OptionOwner` (actually a `Selection` or a `OptionGroup`)

    - #### fromIdentifiable

          public <I extends Identifiable<?>> T fromIdentifiable(String id,
                                                                String titleId,
                                                                Iterable<? extends I> allElements,
                                                                Collection<? extends I> selectedElements,
                                                                NameProvider<I> nameProvider)

      Builds and returns a new `OptionOwner` using the given `Identifiable` elements. For the `Option`'s id, `Identifiable.getId()` is used. If no `NameProvider` is given, `Object.toString()` is used for the `Option`'s value.
      Parameters:
        `id` - the id of the `OptionOwner`
        `titleId` - the title-id of the `OptionOwner` (see `Label.getId()`).
        `allElements` - the elements to create `Option`s from
        `selectedElements` - the selected elements
        `nameProvider` - a `NameProvider` (optional)
      Returns:
        a new `OptionOwner` (actually a `Selection` or a `OptionGroup`)

    - #### fromIdentifiable

          public <I extends Identifiable<?>> T fromIdentifiable(String id,
                                                                String titleId,
                                                                Iterable<? extends I> allElements,
                                                                OptionOwner.Selector selector)

      Builds and returns a new `OptionOwner` using the given `Identifiable` elements. For the `Option`'s id, `Identifiable.getId()` is used, for the value `Object.toString()`.
      Parameters:
        `id` - the id of the `OptionOwner`
        `titleId` - the title-id of the `OptionOwner` (see `Label.getId()`).
        `allElements` - the elements to create `Option`s from
        `selector` - a `OptionOwner.Selector`
      Returns:
        a new `OptionOwner` (actually a `Selection` or a `OptionGroup`)

    - #### fromIdentifiable

          public <I extends Identifiable<?>> T fromIdentifiable(String id,
                                                                String titleId,
                                                                Iterable<? extends I> allElements,
                                                                OptionOwner.Selector selector,
                                                                NameProvider<I> nameProvider)

      Builds and returns a new `OptionOwner` using the given `Identifiable` elements. For the `Option`'s id, `Identifiable.getId()` is used. If no `NameProvider` is given, `Object.toString()` is used for the `Option`'s value.
      Parameters:
        `id` - the id of the `OptionOwner`
        `titleId` - the title-id of the `OptionOwner` (see `Label.getId()`).
        `allElements` - the elements to create `Option`s from
        `selector` - a `OptionOwner.Selector`
        `nameProvider` - a `NameProvider` (optional)
      Returns:
        a new `OptionOwner` (actually a `Selection` or a `OptionGroup`)

    - #### fromEnum

          public <E extends Enum<E>> T fromEnum(String id,
                                                String titleId,
                                                E[] allElements,
                                                Collection<E> selectedElements)

      Builds and returns a new `OptionOwner` using the given `Enum` elements. For both, the `Option` 's id and value, `Enum.name()` is used.
      Parameters:
        `id` - the id of the `OptionOwner`
        `titleId` - the title-id of the `OptionOwner` (see `Label.getId()`).
        `allElements` - the elements to create `Option`s from
        `selectedElements` - the selected elements
      Returns:
        a new `OptionOwner` (actually a `Selection` or a `OptionGroup`)

    - #### fromEnum

          public <E extends Enum<E>> T fromEnum(String id,
                                                String titleId,
                                                E[] allElements,
                                                E selectedElement)

      Builds and returns a new `OptionOwner` using the given `Enum` elements. For both, the `Option` 's id and value, `Enum.name()` is used.
      Parameters:
        `id` - the id of the `OptionOwner`
        `titleId` - the title-id of the `OptionOwner` (see `Label.getId()`).
        `allElements` - the elements to create `Option`s from
        `selectedElement` - the selected element
      Returns:
        a new `OptionOwner` (actually a `Selection` or a `OptionGroup`)

    - #### fromEnum

          public <E extends Enum<E>> T fromEnum(String id,
                                                String titleId,
                                                E[] allElements,
                                                Collection<E> selectedElements,
                                                NameProvider<E> nameProvider)

      Builds and returns a new `OptionOwner` using the given `Enum` elements. For the `Option`'s id, `Enum.name()` is used. If no `NameProvider` is given, `Enum.name()` is also used for the `Option`'s value.
      Parameters:
        `id` - the id of the `OptionOwner`
        `titleId` - the title-id of the `OptionOwner` (see `Label.getId()`).
        `allElements` - the elements to create `Option`s from
        `selectedElements` - the selected elements
        `nameProvider` - a `NameProvider` (optional)
      Returns:
        a new `OptionOwner` (actually a `Selection` or a `OptionGroup`)

    - #### fromEnum

          public <E extends Enum<E>> T fromEnum(String id,
                                                String titleId,
                                                E[] allElements,
                                                E selectedElement,
                                                NameProvider<E> nameProvider)

      Builds and returns a new `OptionOwner` using the given `Enum` elements. For the `Option`'s id, `Enum.name()` is used. If no `NameProvider` is given, `Enum.name()` is also used for the `Option`'s value.
      Parameters:
        `id` - the id of the `OptionOwner`
        `titleId` - the title-id of the `OptionOwner` (see `Label.getId()`).
        `allElements` - the elements to create `Option`s from
        `selectedElement` - the selected element
        `nameProvider` - a `NameProvider` (optional)
      Returns:
        a new `OptionOwner` (actually a `Selection` or a `OptionGroup`)

    - #### fromObjects

          public <S> T fromObjects(String id,
                                   String titleId,
                                   S[] allElements,
                                   OptionOwner.Selector selector)

      Builds and returns a new `OptionOwner` using the given `Object`s. For both, the `Option`'s id and value, `Object.toString()` is used.
      Parameters:
        `id` - the id of the `OptionOwner`
        `titleId` - the title-id of the `OptionOwner` (see `Label.getId()`).
        `allElements` - the elements to create `Option`s from
        `selector` - a `OptionOwner.Selector`
      Returns:
        a new `OptionOwner` (actually a `Selection` or a `OptionGroup`)

    - #### fromObjects

          public <S> T fromObjects(String id,
                                   String titleId,
                                   S[] allElements,
                                   OptionOwner.Selector selector,
                                   NameProvider<S> nameProvider)

      Builds and returns a new `OptionOwner` using the given `Object`s. For the `Option`'s id, `Object.toString()` is used. If no `NameProvider` is given, `Object.toString()` is also used for the `Option`'s value.
      Parameters:
        `id` - the id of the `OptionOwner`
        `titleId` - the title-id of the `OptionOwner` (see `Label.getId()`).
        `allElements` - the elements to create `Option`s from
        `selector` - a `OptionOwner.Selector`
        `nameProvider` - a `NameProvider` (optional)
      Returns:
        a new `OptionOwner` (actually a `Selection` or a `OptionGroup`)

    - #### fromObjects

          public <S> T fromObjects(String id,
                                   String titleId,
                                   S[] allElements,
                                   S... selectedElements)

      Builds and returns a new `OptionOwner` using the given `Object`s. For both, the `Option`'s id and value, `Object.toString()` is used.
      Parameters:
        `id` - the id of the `OptionOwner`
        `titleId` - the title-id of the `OptionOwner` (see `Label.getId()`).
        `allElements` - the elements to create `Option`s from
        `selectedElements` - the selected elements
      Returns:
        a new `OptionOwner` (actually a `Selection` or a `OptionGroup`)

    - #### fromObjects

          public <S> T fromObjects(String id,
                                   String titleId,
                                   S[] allElements,
                                   NameProvider<S> nameProvider,
                                   S... selectedElements)

      Builds and returns a new `OptionOwner` using the given `Object`s. For the `Option`'s id, `Object.toString()` is used. If no `NameProvider` is given, `Object.toString()` is also used for the `Option`'s value.
      Parameters:
        `id` - the id of the `OptionOwner`
        `titleId` - the title-id of the `OptionOwner` (see `Label.getId()`).
        `allElements` - the elements to create `Option`s from
        `selectedElements` - the selected elements
        `nameProvider` - a `NameProvider` (optional)
      Returns:
        a new `OptionOwner` (actually a `Selection` or a `OptionGroup`)

    - #### countHits

          public void countHits(Iterable<Option> options,
                                OptionOwner.HitCounter<String> counter)

      Counts and sets the hits for the options based on their value.
      Parameters:
        `options` - some options
        `counter` - a `OptionOwner.HitCounter`
      See Also:
        `Option.getValue()`, `Option.getHits()`

    - #### countHits

          public void countHits(OptionOwner optionOwner,
                                OptionOwner.HitCounter<String> counter)

      Counts and sets the hits for the owner's options based on their value.
      Parameters:
        `optionOwner` - an `OptionOwner`
        `counter` - a `OptionOwner.HitCounter`
      See Also:
        `Option.getValue()`, `Option.getHits()`

Copyright © 2011–2023 aiticon GmbH. All rights reserved.