org.processmining.plugins.declareminer.visualizing
Class BaseCollection<E extends Base>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<E>
              extended by org.processmining.plugins.declareminer.visualizing.BaseCollection<E>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>, java.util.RandomAccess

public class BaseCollection<E extends Base>
extends java.util.ArrayList<E>

This class is used to store objects that extends class Base, i.e., objects with Integer identification. Each element of the collection has to have a unique ID. On the one hand, this class extends ArrayList, which enables maintaining the order in which elements were added to the collection. On the other hand, this class stores all its elements in a HashMap, which makes sure all elements have unique IDs and enables quick retrieval of objects based on their IDs.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
BaseCollection()
          This constructor initiates the ArrayList and the HashMap map.
 
Method Summary
 boolean add(E e)
          Adds the new element to the collection.
 E getItemWithId(int id)
          Returns the element with given ID.
 int nextId()
          Returns the ID that should be assigned to the next element in order to be successfully added to the collection.
 void remove(E e)
          Removes one element from the collection.
 
Methods inherited from class java.util.ArrayList
add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

BaseCollection

public BaseCollection()
This constructor initiates the ArrayList and the HashMap map.

Method Detail

add

public boolean add(E e)
Adds the new element to the collection. The element with one ID can be added only once.

Specified by:
add in interface java.util.Collection<E extends Base>
Specified by:
add in interface java.util.List<E extends Base>
Overrides:
add in class java.util.ArrayList<E extends Base>
Parameters:
e - is the element to be added

remove

public void remove(E e)
Removes one element from the collection.

Parameters:
e - is the element to be removed

nextId

public int nextId()
Returns the ID that should be assigned to the next element in order to be successfully added to the collection.

Returns:
getMaxId() + 1

getItemWithId

public E getItemWithId(int id)
Returns the element with given ID.

Parameters:
id - of the element to be returned.
Returns:
The element with ID equal to parameter id.