org.eclipse.emf.ecp.common.cachetree
Class AbstractCachedTree<T>

java.lang.Object
  extended by org.eclipse.emf.ecp.common.cachetree.AbstractCachedTree<T>
Type Parameters:
T - the actual value type that is stored by the tree
Direct Known Subclasses:
EMFStoreDirtyDecoratorCachedTree, ValidationService

public abstract class AbstractCachedTree<T>
extends Object

A cached tree resembles a tree structure where each node is associated with a specific value. The value stored by parent nodes within the tree hereby are influenced by the values stored within their children. Thus, if the value of a child changes, it needs to be propagated upwards. Analogously, if the child is deleted the value associated with the deleted child must not influence the value of the parent anymore. This class is responsible for adding and removing nodes and for correctly maintaining such parent/child relationships.

Author:
emueller, Tobias Verhoeven

Constructor Summary
AbstractCachedTree(IExcludedObjectsCallback callback)
          Private constructor.
 
Method Summary
 void clear()
          Clears the cache.
 T getCachedValue(Object eObject)
          Returns the cached value stored for the given EObject.
abstract  T getDefaultValue()
          Returns the default value for a cached node.
The root value will be initialized with this value, too
 T getRootValue()
          Returns the root value of this tree.
Note that the root is purely notional.
 void remove(org.eclipse.emf.ecore.EObject eObject)
          Removes the cache entry that contains the given EObject.
 Set<org.eclipse.emf.ecore.EObject> update(org.eclipse.emf.ecore.EObject eObject, T value)
          Updates the cached entry for the given EObject with the given value.
If the cached entry does not yet exist, it will be created.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCachedTree

public AbstractCachedTree(IExcludedObjectsCallback callback)
Private constructor.

Parameters:
callback - the IExcludedObjectsCallback to use when checking when to stop
Method Detail

getDefaultValue

public abstract T getDefaultValue()
Returns the default value for a cached node.
The root value will be initialized with this value, too

Returns:
the default value for a cached tree node

update

public Set<org.eclipse.emf.ecore.EObject> update(org.eclipse.emf.ecore.EObject eObject,
                                                 T value)
Updates the cached entry for the given EObject with the given value.
If the cached entry does not yet exist, it will be created.

Parameters:
eObject - the EObject
value - the value associated with the EObject
Returns:
set of affected eobjects

getRootValue

public T getRootValue()
Returns the root value of this tree.
Note that the root is purely notional.

Returns:
the node

getCachedValue

public T getCachedValue(Object eObject)
Returns the cached value stored for the given EObject.

Parameters:
eObject - the EObject whose cached value should be found
Returns:
the cached value associated with the given EObject, if found, otherwise the default value which is returned via getDefaultValue()

remove

public void remove(org.eclipse.emf.ecore.EObject eObject)
Removes the cache entry that contains the given EObject.

Parameters:
eObject - the EObject that needs to be removed from the cached tree

clear

public void clear()
Clears the cache.



Copyright © 2014. All Rights Reserved.