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
Modifier and TypeFieldDescriptionstatic final Step
static final Comparator
static final Nomenclature
-
Constructor Summary
ConstructorDescriptionCreates aNomenclature
with label size equal to 1.Nomenclature
(int numberOfLabels) Creates aNomenclature
with the specified label size. -
Method Summary
Modifier and TypeMethodDescriptionaddItem
(NomenclatureItem<T> anItem) Adds aNomenclatureItem
to this instance.addItemValue
(T aValue, String aLabel) Adds aNomenclatureItemValue
with the specified content to this instance.addItemValue
(T aValue, String[] labels) Adds to this instance aNomenclatureItemValue
with the specified content.addItemValue
(T aValue, String[] labels, Locale[] locales) Adds aNomenclatureItemValue
with the specified content to this instance.addItemWithMessage
(T aValue, UserMessage aMessage) Adds aNomenclatureItemWithMessage
with the specified content to this instance.addNomenclature
(Nomenclature<T> anotherNomenclature) Adds all the items of the specifiedNomenclature
to this instance.static final <T> Comparator<NomenclatureItem<T>>
Returns a label comparator.static final <T> Nomenclature<T>
empty()
Returns the empty nomenclature (immutable).boolean
findNomenclatureItemWithValue
(Object aSearchedValue) Returns the firstNomenclatureItem
whose 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
.int
Returns the number of labels that each item of thisNomenclature
must have.int
getSize()
Returns the number of items in thisNomenclature
.int
hashCode()
void
setItems
(List<NomenclatureItem<T>> aList) void
setLastItemAsDefault
(boolean isDefault) Set the default to the last added item.void
toString()
-
Field Details
-
_items
-
EMPTY
-
ComparatorByLabel
-
-
Constructor Details
-
Nomenclature
public Nomenclature()Creates aNomenclature
with label size equal to 1. -
Nomenclature
public Nomenclature(int numberOfLabels) Creates aNomenclature
with 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 aNomenclatureItem
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:
-
addItemValue
Adds to this instance aNomenclatureItemValue
with the specified content. -
addItemValue
Adds aNomenclatureItemValue
with the specified content to this instance. Each label corresponds to the locale at the same index. -
addItemValue
Adds aNomenclatureItemValue
with the specified content to this instance. -
addItemWithMessage
Adds aNomenclatureItemWithMessage
with the specified content to this instance.- Since:
- 5.7.1
- See Also:
-
addNomenclature
Adds all the items of the specifiedNomenclature
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:
-
equals
-
hashCode
public int hashCode() -
findNomenclatureItemWithValue
Returns the firstNomenclatureItem
whose value is equal to the argument. Returnsnull
if no item is found. -
getAllValues
Returns all the item's values. Only items that returntrue
for 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 thisNomenclature
must 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
-