Package com.onwbp.base.text

# Class Nomenclature<T>

java.lang.Object
com.onwbp.base.text.Nomenclature<T>

public class Nomenclature<T> extends Object
A `Nomenclature` is an ordered collection of `NomenclatureItem` instances.

See Also:
  - `NomenclatureItem`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final Step`
  `_items`
  `static final Comparator`
  `ComparatorByLabel`
  `static final Nomenclature`
  `EMPTY`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Nomenclature()`
  Creates a `Nomenclature` with label size equal to 1.
  `Nomenclature(int numberOfLabels)`
  Creates a `Nomenclature` with the specified label size.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Nomenclature<T>`
  `addItem(NomenclatureItem<T> anItem)`
  Adds a `NomenclatureItem` to this instance.
  `Nomenclature<T>`
  `addItemValue(T aValue, String aLabel)`
  Adds a `NomenclatureItemValue` with the specified content to this instance.
  `Nomenclature<T>`
  `addItemValue(T aValue, String[] labels)`
  Adds to this instance a `NomenclatureItemValue` with the specified content.
  `Nomenclature<T>`
  `addItemValue(T aValue, String[] labels, Locale[] locales)`
  Adds a `NomenclatureItemValue` with the specified content to this instance.
  `Nomenclature<T>`
  `addItemWithMessage(T aValue, UserMessage aMessage)`
  Adds a `NomenclatureItemWithMessage` with the specified content to this instance.
  `Nomenclature<T>`
  `addNomenclature(Nomenclature<T> anotherNomenclature)`
  Adds all the items of the specified `Nomenclature` to this instance.
  `static final <T> Comparator<NomenclatureItem<T>>`
  `comparatorByLabel()`
  Returns a label comparator.
  `static final <T> Nomenclature<T>`
  `empty()`
  Returns the empty nomenclature (immutable).
  `boolean`
  `equals(Object x)`
  `NomenclatureItem<T>`
  `findNomenclatureItemWithValue(Object aSearchedValue)`
  Returns the first `NomenclatureItem` whose value is equal to the argument.
  `List<T>`
  `getAllValues()`
  Returns all the item's values.
  `static final <U> Comparator<NomenclatureItem<U>>`
  `getComparatorByLabel()`
  `List<NomenclatureItem<T>>`
  `getItems()`
  Returns all items (internal, used for debug tag)
  `NomenclatureItem<T>`
  `getItems(int index)`
  Returns the item at the specified position in this `Nomenclature`.
  `Iterator<NomenclatureItem<T>>`
  `getItemsIterator()`
  Returns an iterator over all the items of this `Nomenclature`.
  `int`
  `getLabelsSize()`
  Returns the number of labels that each item of this `Nomenclature` must have.
  `int`
  `getSize()`
  Returns the number of items in this `Nomenclature`.
  `int`
  `hashCode()`
  `void`
  `setItems(List<NomenclatureItem<T>> aList)`
  `void`
  `setLastItemAsDefault(boolean isDefault)`
  Set the default to the last added item.
  `void`
  `sortByLabel()`
  `String`
  `toString()`

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

  `getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### _items

    public static final Step _items

  - ### EMPTY

    public static final Nomenclature EMPTY

  - ### ComparatorByLabel

    public static final Comparator ComparatorByLabel

- ## Constructor Details

  - ### Nomenclature

    public Nomenclature()
    Creates a `Nomenclature` with label size equal to 1.

  - ### Nomenclature

    public Nomenclature(int numberOfLabels)
    Creates a `Nomenclature` with the specified label size.
    See Also:
      - `addItem(com.onwbp.base.text.NomenclatureItem<T>)`
      - `getLabelsSize()`

- ## Method Details

  - ### empty

    public static final <T> Nomenclature<T> empty()
    Returns the empty nomenclature (immutable). Unlike the like-named field, this method is parameterized.
    Since:
      5.8.1

  - ### comparatorByLabel

    public static final <T> Comparator<NomenclatureItem<T>> comparatorByLabel()
    Returns a label comparator. Unlike the like-named field, this method is parameterized.
    Since:
      5.8.1

  - ### addItem

    public Nomenclature<T> addItem(NomenclatureItem<T> anItem) throws IllegalArgumentException
    Adds a `NomenclatureItem` to this instance. The item is added at the end of the ordered list of items.
    Returns:
      this instance
    Throws:
      `IllegalArgumentException` - If the item to be added does not have the same number of labels as the number specified in this constructor.
    See Also:
      - `Nomenclature(int)`
      - `addNomenclature(com.onwbp.base.text.Nomenclature<T>)`

  - ### addItemValue

    public Nomenclature<T> addItemValue(T aValue, String[] labels)
    Adds to this instance a `NomenclatureItemValue` with the specified content.
    See Also:
      - `addItem(com.onwbp.base.text.NomenclatureItem<T>)`

  - ### addItemValue

    public Nomenclature<T> addItemValue(T aValue, String[] labels, Locale[] locales)
    Adds a `NomenclatureItemValue` with the specified content to this instance. Each label corresponds to the locale at the same index.
    See Also:
      - `throws IllegalArgumentException if arrays do not have same size.`

  - ### addItemValue

    public Nomenclature<T> addItemValue(T aValue, String aLabel)
    Adds a `NomenclatureItemValue` with the specified content to this instance.
    See Also:
      - `addItem(com.onwbp.base.text.NomenclatureItem<T>)`

  - ### addItemWithMessage

    public Nomenclature<T> addItemWithMessage(T aValue, UserMessage aMessage)
    Adds a `NomenclatureItemWithMessage` with the specified content to this instance.
    Since:
      5.7.1
    See Also:
      - `addItem(com.onwbp.base.text.NomenclatureItem<T>)`

  - ### addNomenclature

    public Nomenclature<T> addNomenclature(Nomenclature<T> anotherNomenclature) throws RuntimeException
    Adds all the items of the specified `Nomenclature` to this instance. Items are added in the same order at the end of the list of items.
    Returns:
      this instance
    Throws:
      `RuntimeException` - If the nomenclature to be added does not have the same number of labels as the number specified in this instance.
    See Also:
      - `addItem(com.onwbp.base.text.NomenclatureItem<T>)`

  - ### equals

    public boolean equals(Object x)
    Overrides:
      `equals` in class `Object`

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### findNomenclatureItemWithValue

    public NomenclatureItem<T> findNomenclatureItemWithValue(Object aSearchedValue)
    Returns the first `NomenclatureItem` whose value is equal to the argument. Returns `null` if no item is found.

  - ### getAllValues

    public List<T> getAllValues()
    Returns all the item's values. Only items that return `true` for the method `isValueItem()` are included in the returned list.
    See Also:
      - `NomenclatureItem.isValueItem()`

  - ### getComparatorByLabel

    public static final <U> Comparator<NomenclatureItem<U>> getComparatorByLabel()

  - ### getItems

    public List<NomenclatureItem<T>> getItems()
    Returns all items (internal, used for debug tag)

  - ### getItems

    public NomenclatureItem<T> getItems(int index)
    Returns the item at the specified position in this `Nomenclature`.

  - ### getItemsIterator

    public Iterator<NomenclatureItem<T>> getItemsIterator()
    Returns an iterator over all the items of this `Nomenclature`.

  - ### getLabelsSize

    public int getLabelsSize()
    Returns the number of labels that each item of this `Nomenclature` must have.
    See Also:
      - `Nomenclature(int)`

  - ### getSize

    public int getSize()
    Returns the number of items in this `Nomenclature`.

  - ### setItems

    public void setItems(List<NomenclatureItem<T>> aList)
    See Also:
      - `addItemValue(Object, String)`
      - `addNomenclature(Nomenclature)`

  - ### setLastItemAsDefault

    public void setLastItemAsDefault(boolean isDefault) throws IllegalStateException
    Set the default to the last added item.
    Throws:
      `IllegalStateException` - If this nomenclature has no items
    See Also:
      - `NomenclatureItem.setDefaultItem(boolean)`

  - ### sortByLabel

    public void sortByLabel()

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`