E
- the type of the elements in this list.public class ListTermImpl<E> extends AbstractList<E> implements ListTerm<E>
A list implementation that integrates nicely into the AST.
modCount
Modifier | Constructor and Description |
---|---|
|
ListTermImpl()
Constructs an empty list term that accepts all Objects.
|
protected |
ListTermImpl(BaseFactory factory) |
Modifier and Type | Method and Description |
---|---|
<R> R |
accept(Visitor<R> v)
Accepts a visitor.
|
void |
add(int index,
E element)
Inserts the specified element at the specified position in this list.
|
int |
annsSize()
Returns whether the annotation list size.
|
Term |
create(Object[] args)
Creates a new object of the implementing class
with the objects in
args as its children. |
E |
get(int index)
Returns the element at the specified position in this list.
|
<T> T |
getAnn(Class<T> aClass)
Returns one of the
aClass annotations of this
term, or null if the term does not contain an
annotation of this type. |
List<Object> |
getAnns()
Returns a list of annotations.
|
Object[] |
getChildren()
Returns an array of all the children of this term,
thus providing the possibility to write generic
visitors that traverse a tree of Z terms without even knowing
the kind of term they are visiting.
|
boolean |
hasAnn()
Returns true when
annsSize() has more than zero elements. |
<T> boolean |
hasAnn(Class<T> aClass)
Checks whether the term has any annotation of the given class type
|
E |
remove(int index)
Removes the element at the specified position in this list.
|
<T> void |
removeAnn(Class<T> aClass)
Removes all annotations of the specific class.
|
<T> boolean |
removeAnn(T annotation)
Removes a specific annotation, if present.
|
E |
set(int index,
E element)
Replaces the elment at the specifed position
in this list with the specified element.
|
int |
size()
Returns the number of components in this list.
|
String |
toString() |
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
add, addAll, addAll, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeAll, replaceAll, retainAll, sort, spliterator, subList, toArray, toArray
parallelStream, removeIf, stream
public ListTermImpl()
protected ListTermImpl(BaseFactory factory)
public String toString()
toString
in class AbstractCollection<E>
public void add(int index, E element)
add
in interface List<E>
add
in class AbstractList<E>
index
- the index at which the specified element is to be inserted.element
- the element to be inserted.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > size())
.public E get(int index)
get
in interface List<E>
get
in class AbstractList<E>
index
- the index of the elment to be returned.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size())
.public E remove(int index)
remove
in interface List<E>
remove
in class AbstractList<E>
index
- the index of the element to be removed.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= size())
.public E set(int index, E element)
set
in interface List<E>
set
in class AbstractList<E>
index
- the position of the element to replace.element
- the new element to be stored at the specified position.ArrayIndexOutOfBoundsException
- if index
is out of range (index < 0 || index >= size())
.public int size()
size
in interface Collection<E>
size
in interface List<E>
size
in class AbstractCollection<E>
public <R> R accept(Visitor<R> v)
Term
Accepts a visitor.
This method provides support for the visitor design pattern. Depending on the kind of visitor interfaces the given visitor implements, the visited term chooses the visit-method which fits best and returns the object that a call to this method returns.
accept
in interface Term
v
- the visitor that wants to visit this term.net.sourceforge.czt.base.visitor
public Object[] getChildren()
Term
Returns an array of all the children of this term, thus providing the possibility to write generic visitors that traverse a tree of Z terms without even knowing the kind of term they are visiting.
The order and types of children is the same as the arguments to the corresponding create method in the factory.
getChildren
in interface Term
public Term create(Object[] args)
Term
Creates a new object of the implementing class
with the objects in args
as its children.
The order and type of the children is similar
to the one returned by Term.getChildren()
.
This method is intended to be used together with method
Term.getChildren()
by generic visitors.
create
in interface Term
args
- the children of the term to be created.t
such that
this.getClass() == t.getClass()
and forall i
t.getChildren()[i] == args[i]
.Term.getChildren()
public List<Object> getAnns()
Term
Returns a list of annotations.
To add or remove elements, use the methods provided by the List interface (that's why there is no need for a setter method).
Avoid calling this method directly and prefer to check with hasAnn()
first. This delays creation of underlying arrays and lead to considerable memory
optimisation on large specs.
public int annsSize()
Term
public boolean hasAnn()
Term
annsSize()
has more than zero elements.public <T> T getAnn(Class<T> aClass)
Term
Returns one of the aClass
annotations of this
term, or null
if the term does not contain an
annotation of this type.
public <T> boolean hasAnn(Class<T> aClass)
Term
public <T> void removeAnn(Class<T> aClass)
Term
public <T> boolean removeAnn(T annotation)
Term
Copyright © 2003–2016 Community Z Tools Project. All rights reserved.