T
- an extension of AnnotatedEntity
public class AnnotatedEntityList<T extends AnnotatedEntity> extends Object
AnnotatedEntity
s where
elements can be accessed either by index or by the name
of the AnnotatedEntity
.Constructor and Description |
---|
AnnotatedEntityList()
Creates a new
AnnotatedEntityList with an initial
capacity of 10. |
AnnotatedEntityList(int initialCapacity)
Creates a new
AnnotatedEntityList with given initial
capacity. |
Modifier and Type | Method and Description |
---|---|
void |
add(int idx,
T entity)
|
void |
add(T... entities)
Adds all
AnnotatedEntity s in entities
to the list. |
void |
addAll(Collection<? extends T> entities)
Adds all
AnnotatedEntity s in entities
to the list. |
T |
get(int index)
Returns the
AnnotatedEntity at index index
in the list. |
T |
get(String name)
Returns the
AnnotatedEntity with name name
in the list. |
String[] |
getNames()
Returns the names of all
AnnotatedEntity s in the list. |
T |
remove(int idx)
Removes and returns the
AnnotatedEntity at index idx . |
void |
set(int idx,
T entity)
|
int |
size()
Returns the number of
AnnotatedEntity s (not the capacity)
in the AnnotatedEntityList . |
<E extends T> |
toArray(E[] ar)
Returns the
AnnotatedEntity s in this list
as an array. |
public AnnotatedEntityList()
AnnotatedEntityList
with an initial
capacity of 10.public AnnotatedEntityList(int initialCapacity)
AnnotatedEntityList
with given initial
capacity.initialCapacity
- the initial capacitypublic void set(int idx, T entity)
idx
- the indexentity
- the new AnnotatedEntity
at index idx
public T remove(int idx)
AnnotatedEntity
at index idx
.idx
- the index of the AnnotatedEntity
to be removedAnnotatedEntity
that has been at index idx
public void add(int idx, T entity)
AnnotatedEntity
entity
at index idx
to the list. If entities
contains AnnotatedEntity
s with duplicate names,
or an AnnotatedEntity
with identical name already exists in the list,
an IllegalArgumentException
is thrown.idx
- the indexentity
- the added AnnotatedEntity
List.add(int, Object)
public void add(T... entities)
AnnotatedEntity
s in entities
to the list. If entities
contains AnnotatedEntity
s with duplicate names,
or an AnnotatedEntity
with identical name already exists in the list,
an IllegalArgumentException
is thrown.entities
- the added AnnotatedEntity
public void addAll(Collection<? extends T> entities)
AnnotatedEntity
s in entities
to the list. If entities
contains AnnotatedEntity
s with duplicate names,
or an AnnotatedEntity
with identical name already exists in the list,
an IllegalArgumentException
is thrown.entities
- the added AnnotatedEntity
public T get(int index)
AnnotatedEntity
at index index
in the list.index
- the indexAnnotatedEntity
at index
public T get(String name)
AnnotatedEntity
with name name
in the list.name
- the nameAnnotatedEntity
with name name
AnnotatedEntity.getName()
public int size()
AnnotatedEntity
s (not the capacity)
in the AnnotatedEntityList
.AnnotatedEntity
spublic String[] getNames()
AnnotatedEntity
s in the list.AnnotatedEntity.getName()
public <E extends T> E[] toArray(E[] ar)
AnnotatedEntity
s in this list
as an array. This method behaves exactly like ArrayList.toArray(Object[])
.E
- a sub-type of AnnotatedEntity
ar
- an array of the desired typeAnnotatedEntity
s in this list as an array