public class Nomenclature<T> extends Object
Nomenclature
is an ordered collection of NomenclatureItem
instances.NomenclatureItem
Modifier and Type | Field and Description |
---|---|
static Step |
_items |
static Comparator |
ComparatorByLabel |
static Nomenclature |
EMPTY |
Constructor and Description |
---|
Nomenclature()
Creates a
Nomenclature with label size equal to 1. |
Nomenclature(int numberOfLabels)
Creates a
Nomenclature with the specified label size. |
Modifier and Type | Method and 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 <T> Comparator<NomenclatureItem<T>> |
comparatorByLabel()
Returns a label comparator.
|
static <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 <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() |
public static final Step _items
public static final Nomenclature EMPTY
public static final Comparator ComparatorByLabel
public Nomenclature()
Nomenclature
with label size equal to 1.public Nomenclature(int numberOfLabels)
Nomenclature
with the specified label size.public static final <T> Nomenclature<T> empty()
public static final <T> Comparator<NomenclatureItem<T>> comparatorByLabel()
public Nomenclature<T> addItem(NomenclatureItem<T> anItem) throws IllegalArgumentException
NomenclatureItem
to this instance. The item is added at the end of the ordered list of
items.IllegalArgumentException
- If the item to be added does not have the same number of labels as the number
specified in this constructor.Nomenclature(int)
,
addNomenclature(com.onwbp.base.text.Nomenclature<T>)
public Nomenclature<T> addItemValue(T aValue, String[] labels)
NomenclatureItemValue
with the specified content.public Nomenclature<T> addItemValue(T aValue, String[] labels, Locale[] locales)
NomenclatureItemValue
with the specified content to this instance.
Each label corresponds to the locale at the same index.public Nomenclature<T> addItemValue(T aValue, String aLabel)
NomenclatureItemValue
with the specified content to this instance.public Nomenclature<T> addItemWithMessage(T aValue, UserMessage aMessage)
NomenclatureItemWithMessage
with the specified content to this instance.addItem(com.onwbp.base.text.NomenclatureItem<T>)
public Nomenclature<T> addNomenclature(Nomenclature<T> anotherNomenclature) throws RuntimeException
Nomenclature
to this instance. Items are added in the same
order at the end of the list of items.RuntimeException
- If the nomenclature to be added does not have the same number of labels as the
number specified in this instance.addItem(com.onwbp.base.text.NomenclatureItem<T>)
public NomenclatureItem<T> findNomenclatureItemWithValue(Object aSearchedValue)
NomenclatureItem
whose value is equal to the
argument. Returns null
if no item is found.public List<T> getAllValues()
true
for the method
isValueItem()
are included in the returned list.NomenclatureItem.isValueItem()
public static final <U> Comparator<NomenclatureItem<U>> getComparatorByLabel()
public List<NomenclatureItem<T>> getItems()
public NomenclatureItem<T> getItems(int index)
Nomenclature
.public Iterator<NomenclatureItem<T>> getItemsIterator()
Nomenclature
.public int getLabelsSize()
Nomenclature
must have.Nomenclature(int)
public int getSize()
Nomenclature
.public void setItems(List<NomenclatureItem<T>> aList)
public void setLastItemAsDefault(boolean isDefault) throws IllegalStateException
IllegalStateException
- If this nomenclature has no itemsNomenclatureItem.setDefaultItem(boolean)
public void sortByLabel()