Class WriteableObjectPoolImpl<T extends DataObject>
- java.lang.Object
-
- de.uni_trier.wi2.procake.utils.composition.FactoryObjectImplementation
-
- de.uni_trier.wi2.procake.data.objectpool.impl.WriteableObjectPoolImpl<T>
-
- All Implemented Interfaces:
ObjectPoolFactoryImplementation
,ReadableObjectPool<T>
,WriteableObjectPool<T>
,Iterable<T>
public class WriteableObjectPoolImpl<T extends DataObject> extends FactoryObjectImplementation implements WriteableObjectPool<T>
- Author:
- Rainer Maximini
-
-
Constructor Summary
Constructors Constructor Description WriteableObjectPoolImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WriteableObjectPool<T>
copy()
Collection<T>
getCollection()
String
getId()
Each Pool must have an Id.Set<String>
getNESTGraphIds()
Set<NESTWorkflowObject>
getNESTGraphObjectsRecursively()
T
getObject(String objectId)
Set<String>
getObjectIds()
Set<String>
getObjectIds(DataClass dataClass)
List<Parameter>
getParameters()
boolean
hasSameValueAsIn(ReadableObjectPool objectPool)
This method makes a deep compare.DataObjectIterator<T>
iterator()
String
newObjectId(String base, String offset)
void
postInit()
Called after all factories are initialized withFactoryObjectImplementation.preInit(AbstractParameter[])
and bind to the factory.void
preInit(AbstractParameter[] parameter)
Called directly after creating the implementation.T
remove(String objectId)
Removes the object with the given offset from the pool.T
remove(T object)
Removes the given data object from the pool.void
removeAll()
Removes all items from the poolint
size()
void
sort(Comparator<T> comparator)
Sorts the objects in pool using the given comparator.String
store(T object)
Stores a givenDataObject
into the pool.Set<String>
storeAll(ReadableObjectPool<T> objects)
Set<String>
storeAll(Collection<T> objects)
Stream<T>
stream()
This method is a short call for supplying a stream access to the graphs in the pool.String
toXML()
Converts object pool to XML-
Methods inherited from class de.uni_trier.wi2.procake.utils.composition.FactoryObjectImplementation
getParameter, initParametersBasedOn
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
getId
public String getId()
Description copied from interface:ReadableObjectPool
Each Pool must have an Id. This Id is used as base in objectId.- Specified by:
getId
in interfaceReadableObjectPool<T extends DataObject>
-
getObject
public T getObject(String objectId)
- Specified by:
getObject
in interfaceReadableObjectPool<T extends DataObject>
- Returns:
- The object with the given id.
-
getObjectIds
public Set<String> getObjectIds()
- Specified by:
getObjectIds
in interfaceReadableObjectPool<T extends DataObject>
- Returns:
- The set of all object ids.
-
getObjectIds
public Set<String> getObjectIds(DataClass dataClass)
- Specified by:
getObjectIds
in interfaceReadableObjectPool<T extends DataObject>
- Returns:
- A set of the object ids for the specified data class.
-
getParameters
public List<Parameter> getParameters()
- Specified by:
getParameters
in classFactoryObjectImplementation
- Returns:
- Returns a list of available parameters in the implementation. This method can be called
without initialization and is never
null
.
-
iterator
public DataObjectIterator<T> iterator()
- Specified by:
iterator
in interfaceIterable<T extends DataObject>
- Specified by:
iterator
in interfaceReadableObjectPool<T extends DataObject>
- Returns:
- An iterator over all
DataObject
s.
-
newObjectId
public String newObjectId(String base, String offset)
- Specified by:
newObjectId
in interfaceObjectPoolFactoryImplementation
-
postInit
public void postInit()
Description copied from class:FactoryObjectImplementation
Called after all factories are initialized withFactoryObjectImplementation.preInit(AbstractParameter[])
and bind to the factory.- Specified by:
postInit
in classFactoryObjectImplementation
-
preInit
public void preInit(AbstractParameter[] parameter)
Description copied from class:FactoryObjectImplementation
Called directly after creating the implementation.- Specified by:
preInit
in classFactoryObjectImplementation
- Parameters:
parameter
- The parameters to initialize the implementation.
-
remove
public T remove(T object)
Description copied from interface:WriteableObjectPool
Removes the given data object from the pool. The objectId of the removed object should be automatically removed from the object.- Specified by:
remove
in interfaceWriteableObjectPool<T extends DataObject>
- Parameters:
object
- The object to remove- Returns:
- The removed object or
null
if the object was not in the pool.
-
remove
public T remove(String objectId)
Description copied from interface:WriteableObjectPool
Removes the object with the given offset from the pool. The objectId of the removed object should be automatically removed from the object.- Specified by:
remove
in interfaceWriteableObjectPool<T extends DataObject>
- Parameters:
objectId
- The offset of the object that should be removed.- Returns:
- The removed object or
null
if the object was not in the pool.
-
size
public int size()
- Specified by:
size
in interfaceReadableObjectPool<T extends DataObject>
- Returns:
- The number of
DataObject
s in the pool.
-
store
public String store(T object)
Description copied from interface:WriteableObjectPool
Stores a givenDataObject
into the pool. Thereby, a new unique objectI id is automatically created. If the object is already a member of the pool, nothing will happen.- Specified by:
store
in interfaceWriteableObjectPool<T extends DataObject>
- Parameters:
object
- The object that should be added.- Returns:
- The new objectId of the added object.
-
storeAll
public Set<String> storeAll(Collection<T> objects)
- Specified by:
storeAll
in interfaceWriteableObjectPool<T extends DataObject>
- Returns:
-
storeAll
public Set<String> storeAll(ReadableObjectPool<T> objects)
- Specified by:
storeAll
in interfaceWriteableObjectPool<T extends DataObject>
- Returns:
-
removeAll
public void removeAll()
Description copied from interface:WriteableObjectPool
Removes all items from the pool- Specified by:
removeAll
in interfaceWriteableObjectPool<T extends DataObject>
-
getNESTGraphIds
public Set<String> getNESTGraphIds()
- Specified by:
getNESTGraphIds
in interfaceReadableObjectPool<T extends DataObject>
-
getNESTGraphObjectsRecursively
public Set<NESTWorkflowObject> getNESTGraphObjectsRecursively()
- Specified by:
getNESTGraphObjectsRecursively
in interfaceReadableObjectPool<T extends DataObject>
- Returns:
- A set of all
NESTWorkflowObject
s in the pool, no matter how deeply nested.
-
copy
public WriteableObjectPool<T> copy()
- Specified by:
copy
in interfaceWriteableObjectPool<T extends DataObject>
- Returns:
- deep copy of the pool
-
toXML
public String toXML()
Description copied from interface:ReadableObjectPool
Converts object pool to XML- Specified by:
toXML
in interfaceReadableObjectPool<T extends DataObject>
- Returns:
- XML String
-
getCollection
public Collection<T> getCollection()
- Specified by:
getCollection
in interfaceReadableObjectPool<T extends DataObject>
-
sort
public void sort(Comparator<T> comparator)
Description copied from interface:WriteableObjectPool
Sorts the objects in pool using the given comparator.- Specified by:
sort
in interfaceWriteableObjectPool<T extends DataObject>
-
hasSameValueAsIn
public boolean hasSameValueAsIn(ReadableObjectPool objectPool)
Description copied from interface:ReadableObjectPool
This method makes a deep compare. The elements in both pools are compared.- Specified by:
hasSameValueAsIn
in interfaceReadableObjectPool<T extends DataObject>
- Parameters:
objectPool
- The object pool to compare.- Returns:
true
if the givenobject pool
has the same objects as this one.
-
stream
public Stream<T> stream()
Description copied from interface:ReadableObjectPool
This method is a short call for supplying a stream access to the graphs in the pool.- Specified by:
stream
in interfaceReadableObjectPool<T extends DataObject>
- Returns:
- a stream of the pool objects
-
-