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 boolean
add(T e)
Deprecated.boolean
addAll(Collection<? extends T> c)
void
addElement(T element)
Adds a named element.void
clear()
boolean
contains(Object o)
boolean
containsAll(Collection<?> c)
T
get(String name)
Returns element by name.Map<String,T>
getElements()
Returns a copy of elements map only for reading.int
getIndex(String name)
Returns index of element by name.boolean
isEmpty()
Iterator<T>
iterator()
boolean
remove(Object o)
boolean
removeAll(Collection<?> c)
boolean
retainAll(Collection<?> c)
int
size()
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:
isEmpty
in interfaceCollection<T extends NamedElement>
-
iterator
public final Iterator<T> iterator()
- Specified by:
iterator
in interfaceCollection<T extends NamedElement>
- Specified by:
iterator
in interfaceIterable<T extends NamedElement>
-
size
public final int size()
- Specified by:
size
in interfaceCollection<T extends NamedElement>
-
contains
public final boolean contains(Object o)
- Specified by:
contains
in interfaceCollection<T extends NamedElement>
-
toArray
public final Object[] toArray()
- Specified by:
toArray
in interfaceCollection<T extends NamedElement>
-
toArray
public final <A> A[] toArray(A[] a)
- Specified by:
toArray
in interfaceCollection<T extends NamedElement>
-
add
@Deprecated public final boolean add(T e)
Deprecated.- Specified by:
add
in interfaceCollection<T extends NamedElement>
-
remove
public final boolean remove(Object o)
- Specified by:
remove
in interfaceCollection<T extends NamedElement>
-
containsAll
public final boolean containsAll(Collection<?> c)
- Specified by:
containsAll
in interfaceCollection<T extends NamedElement>
-
addAll
public final boolean addAll(Collection<? extends T> c)
- Specified by:
addAll
in interfaceCollection<T extends NamedElement>
-
removeAll
public final boolean removeAll(Collection<?> c)
- Specified by:
removeAll
in interfaceCollection<T extends NamedElement>
-
retainAll
public final boolean retainAll(Collection<?> c)
- Specified by:
retainAll
in interfaceCollection<T extends NamedElement>
-
clear
public final void clear()
- Specified by:
clear
in interfaceCollection<T extends NamedElement>
-
-