Package com.onwbp.base.text
Class Nomenclature<T>
java.lang.Object
com.onwbp.base.text.Nomenclature<T>
A
Nomenclature is an ordered collection of NomenclatureItem instances.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stepstatic final Comparatorstatic final Nomenclature -
Constructor Summary
ConstructorsConstructorDescriptionCreates aNomenclaturewith label size equal to 1.Nomenclature(int numberOfLabels) Creates aNomenclaturewith the specified label size. -
Method Summary
Modifier and TypeMethodDescriptionaddItem(NomenclatureItem<T> anItem) Adds aNomenclatureItemto this instance.addItemValue(T aValue, String aLabel) Adds aNomenclatureItemValuewith the specified content to this instance.addItemValue(T aValue, String[] labels) Adds to this instance aNomenclatureItemValuewith the specified content.addItemValue(T aValue, String[] labels, Locale[] locales) Adds aNomenclatureItemValuewith the specified content to this instance.addItemWithMessage(T aValue, UserMessage aMessage) Adds aNomenclatureItemWithMessagewith the specified content to this instance.addNomenclature(Nomenclature<T> anotherNomenclature) Adds all the items of the specifiedNomenclatureto this instance.static final <T> Comparator<NomenclatureItem<T>>Returns a label comparator.static final <T> Nomenclature<T>empty()Returns the empty nomenclature (immutable).booleanfindNomenclatureItemWithValue(Object aSearchedValue) Returns the firstNomenclatureItemwhose value is equal to the argument.Returns all the item's values.static final <U> Comparator<NomenclatureItem<U>>getItems()Returns all items (internal, used for debug tag)getItems(int index) Returns the item at the specified position in thisNomenclature.Returns an iterator over all the items of thisNomenclature.intReturns the number of labels that each item of thisNomenclaturemust have.intgetSize()Returns the number of items in thisNomenclature.inthashCode()voidsetItems(List<NomenclatureItem<T>> aList) voidsetLastItemAsDefault(boolean isDefault) Set the default to the last added item.voidtoString()
-
Field Details
-
_items
-
EMPTY
-
ComparatorByLabel
-
-
Constructor Details
-
Nomenclature
public Nomenclature()Creates aNomenclaturewith label size equal to 1. -
Nomenclature
public Nomenclature(int numberOfLabels) Creates aNomenclaturewith the specified label size.
-
-
Method Details
-
empty
Returns the empty nomenclature (immutable). Unlike the like-named field, this method is parameterized.- Since:
- 5.8.1
-
comparatorByLabel
Returns a label comparator. Unlike the like-named field, this method is parameterized.- Since:
- 5.8.1
-
addItem
Adds aNomenclatureItemto 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:
-
addItemValue
Adds to this instance aNomenclatureItemValuewith the specified content. -
addItemValue
Adds aNomenclatureItemValuewith the specified content to this instance. Each label corresponds to the locale at the same index. -
addItemValue
Adds aNomenclatureItemValuewith the specified content to this instance. -
addItemWithMessage
Adds aNomenclatureItemWithMessagewith the specified content to this instance.- Since:
- 5.7.1
- See Also:
-
addNomenclature
Adds all the items of the specifiedNomenclatureto 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:
-
equals
-
hashCode
public int hashCode() -
findNomenclatureItemWithValue
Returns the firstNomenclatureItemwhose value is equal to the argument. Returnsnullif no item is found. -
getAllValues
Returns all the item's values. Only items that returntruefor the methodisValueItem()are included in the returned list.- See Also:
-
getComparatorByLabel
-
getItems
Returns all items (internal, used for debug tag) -
getItems
Returns the item at the specified position in thisNomenclature. -
getItemsIterator
Returns an iterator over all the items of thisNomenclature. -
getLabelsSize
public int getLabelsSize()Returns the number of labels that each item of thisNomenclaturemust have.- See Also:
-
getSize
public int getSize()Returns the number of items in thisNomenclature. -
setItems
-
setLastItemAsDefault
Set the default to the last added item.- Throws:
IllegalStateException- If this nomenclature has no items- See Also:
-
sortByLabel
public void sortByLabel() -
toString
-