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 SummaryFieldsModifier and TypeFieldDescriptionstatic final Stepstatic final Comparatorstatic final Nomenclature
- 
Constructor SummaryConstructorsConstructorDescriptionCreates aNomenclaturewith label size equal to 1.Nomenclature(int numberOfLabels) Creates aNomenclaturewith the specified label size.
- 
Method SummaryModifier 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- 
Nomenclaturepublic Nomenclature()Creates aNomenclaturewith label size equal to 1.
- 
Nomenclaturepublic Nomenclature(int numberOfLabels) Creates aNomenclaturewith the specified label size.
 
- 
- 
Method Details- 
emptyReturns the empty nomenclature (immutable). Unlike the like-named field, this method is parameterized.- Since:
- 5.8.1
 
- 
comparatorByLabelReturns a label comparator. Unlike the like-named field, this method is parameterized.- Since:
- 5.8.1
 
- 
addItemAdds 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:
 
- 
addItemValueAdds to this instance aNomenclatureItemValuewith the specified content.
- 
addItemValueAdds aNomenclatureItemValuewith the specified content to this instance. Each label corresponds to the locale at the same index.
- 
addItemValueAdds aNomenclatureItemValuewith the specified content to this instance.
- 
addItemWithMessageAdds aNomenclatureItemWithMessagewith the specified content to this instance.- Since:
- 5.7.1
- See Also:
 
- 
addNomenclatureAdds 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
- 
hashCodepublic int hashCode()
- 
findNomenclatureItemWithValueReturns the firstNomenclatureItemwhose value is equal to the argument. Returnsnullif no item is found.
- 
getAllValuesReturns all the item's values. Only items that returntruefor the methodisValueItem()are included in the returned list.- See Also:
 
- 
getComparatorByLabel
- 
getItemsReturns all items (internal, used for debug tag)
- 
getItemsReturns the item at the specified position in thisNomenclature.
- 
getItemsIteratorReturns an iterator over all the items of thisNomenclature.
- 
getLabelsSizepublic int getLabelsSize()Returns the number of labels that each item of thisNomenclaturemust have.- See Also:
 
- 
getSizepublic int getSize()Returns the number of items in thisNomenclature.
- 
setItems
- 
setLastItemAsDefaultSet the default to the last added item.- Throws:
- IllegalStateException- If this nomenclature has no items
- See Also:
 
- 
sortByLabelpublic void sortByLabel()
- 
toString
 
-