Package ru.curs.celesta.score
Class NamedElementHolder<T extends NamedElement>
- java.lang.Object
-
- ru.curs.celesta.score.NamedElementHolder<T>
-
- Type Parameters:
T- type of named elements in the collection.
- All Implemented Interfaces:
Iterable<T>,Collection<T>
public abstract class NamedElementHolder<T extends NamedElement> extends Object implements Collection<T>
A collection of named elements that may only contain one element per each name. Provides uniqueness of names and access by name. For example these may be tables in a grain, fields in a key etc. The implementation of interface Collection is done only for the purpose of ObjectAid utility to correctly build a UML diagram (taking a field of NamedElementHolder type as a multi-reference).
-
-
Constructor Summary
Constructors Constructor Description NamedElementHolder()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanadd(T e)Deprecated.booleanaddAll(Collection<? extends T> c)voidaddElement(T element)Adds a named element.voidclear()booleancontains(Object o)booleancontainsAll(Collection<?> c)Tget(String name)Returns element by name.Map<String,T>getElements()Returns a copy of elements map only for reading.intgetIndex(String name)Returns index of element by name.booleanisEmpty()Iterator<T>iterator()booleanremove(Object o)booleanremoveAll(Collection<?> c)booleanretainAll(Collection<?> c)intsize()Object[]toArray()<A> A[]toArray(A[] a)-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
-
-
-
Method Detail
-
getElements
public Map<String,T> getElements()
Returns a copy of elements map only for reading.- Returns:
-
addElement
public final void addElement(T element) throws ParseException
Adds a named element.- Parameters:
element- element to add- Throws:
ParseException- if an element with the same name already exists.
-
get
public final T get(String name)
Returns element by name.- Parameters:
name- element name (identifier)- Returns:
-
getIndex
public final int getIndex(String name)
Returns index of element by name.- Parameters:
name- element name (identifier)- Returns:
-
isEmpty
public final boolean isEmpty()
- Specified by:
isEmptyin interfaceCollection<T extends NamedElement>
-
iterator
public final Iterator<T> iterator()
- Specified by:
iteratorin interfaceCollection<T extends NamedElement>- Specified by:
iteratorin interfaceIterable<T extends NamedElement>
-
size
public final int size()
- Specified by:
sizein interfaceCollection<T extends NamedElement>
-
contains
public final boolean contains(Object o)
- Specified by:
containsin interfaceCollection<T extends NamedElement>
-
toArray
public final Object[] toArray()
- Specified by:
toArrayin interfaceCollection<T extends NamedElement>
-
toArray
public final <A> A[] toArray(A[] a)
- Specified by:
toArrayin interfaceCollection<T extends NamedElement>
-
add
@Deprecated public final boolean add(T e)
Deprecated.- Specified by:
addin interfaceCollection<T extends NamedElement>
-
remove
public final boolean remove(Object o)
- Specified by:
removein interfaceCollection<T extends NamedElement>
-
containsAll
public final boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<T extends NamedElement>
-
addAll
public final boolean addAll(Collection<? extends T> c)
- Specified by:
addAllin interfaceCollection<T extends NamedElement>
-
removeAll
public final boolean removeAll(Collection<?> c)
- Specified by:
removeAllin interfaceCollection<T extends NamedElement>
-
retainAll
public final boolean retainAll(Collection<?> c)
- Specified by:
retainAllin interfaceCollection<T extends NamedElement>
-
clear
public final void clear()
- Specified by:
clearin interfaceCollection<T extends NamedElement>
-
-