org.eclipse.ocl.examples.library.executor
Class LazyModelManager

java.lang.Object
  extended by org.eclipse.ocl.examples.library.executor.LazyModelManager
All Implemented Interfaces:
DomainModelManager
Direct Known Subclasses:
PivotModelManager

public abstract class LazyModelManager
extends java.lang.Object
implements DomainModelManager

A self-populating map that lazily creates the extent of a class when asked for it.

Note that this implementation violates the contract of the Map API as follows:

In practice, this does not matter because this map is only used for providing class extents to the OCL engine, and it only does look-up by key. Moreover, this isn't strictly a violation of any contract because there is no way to distinguish this behaviour from concurrent updates.

See the Environment class for a description of the generic type parameters of this class.

Author:
Christian W. Damus (cdamus)

Field Summary
 
Fields inherited from interface org.eclipse.ocl.examples.domain.evaluation.DomainModelManager
NULL
 
Constructor Summary
LazyModelManager(org.eclipse.emf.ecore.EObject context)
          Initializes me with the context element of an OCL expression evaluation.
 
Method Summary
 java.util.Set<org.eclipse.emf.ecore.EObject> get(DomainType type)
          Lazily computes the extent of the specified class key.
protected abstract  boolean isInstance(DomainType type, org.eclipse.emf.ecore.EObject element)
          Implemented by subclasses to determine whether the specified element is an instance of the specified class, according to the metamodel semantics implemented by the environment that created this extent map.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LazyModelManager

public LazyModelManager(org.eclipse.emf.ecore.EObject context)
Initializes me with the context element of an OCL expression evaluation. I discover the scope of the model from this element.

Parameters:
context - my context element
Method Detail

get

@NonNull
public java.util.Set<org.eclipse.emf.ecore.EObject> get(@NonNull
                                                                DomainType type)
Lazily computes the extent of the specified class key.

Specified by:
get in interface DomainModelManager
Parameters:
type - a class in the model

isInstance

protected abstract boolean isInstance(@NonNull
                                      DomainType type,
                                      @NonNull
                                      org.eclipse.emf.ecore.EObject element)
Implemented by subclasses to determine whether the specified element is an instance of the specified class, according to the metamodel semantics implemented by the environment that created this extent map.

Parameters:
type - a class in the model
element - a potential run-time (M0) instance of that class
Returns:
true if this element is an instance of the given class; false otherwise

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object