Package org.tensorics.core.tree.domain
Class ResolvingContextImpl
- java.lang.Object
-
- org.tensorics.core.tree.domain.ResolvingContextImpl
-
- All Implemented Interfaces:
EditableResolvingContext
,ResolvingContext
public class ResolvingContextImpl extends java.lang.Object implements EditableResolvingContext
The simplest implementation of a resolving context. It is inspired by the original implementation in the TE-MPE analysis package.
-
-
Constructor Summary
Constructors Constructor Description ResolvingContextImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <R,E extends Expression<R>>
voidput(E key, R value)
Put a key and value in the resolving context.void
putAllNew(ResolvingContext context)
Put all new key/value pairs in the resolving context from a previous version of it<R,E extends Expression<R>>
RresolvedValueOf(E expression)
Retrieves the resolved value for the expression.<E extends Expression<?>>
booleanresolves(E expression)
Checks if the expression is resolved within this context.int
size()
Retrieves the amount of resolved values which are stored in the context.
-
-
-
Method Detail
-
putAllNew
public void putAllNew(ResolvingContext context)
Description copied from interface:EditableResolvingContext
Put all new key/value pairs in the resolving context from a previous version of it- Specified by:
putAllNew
in interfaceEditableResolvingContext
- Parameters:
context
- the context to extract the new key/value pairs
-
size
public int size()
Description copied from interface:ResolvingContext
Retrieves the amount of resolved values which are stored in the context.- Specified by:
size
in interfaceResolvingContext
- Returns:
- the number of stored resolved values
-
resolves
public <E extends Expression<?>> boolean resolves(E expression)
Description copied from interface:ResolvingContext
Checks if the expression is resolved within this context. Only if this method returnstrue
, then it is safe to call theResolvingContext.resolvedValueOf(Expression)
method. An expression is seen as resolved, either if the context knows already the resolved value or, if the given expression is a resolved expression by itself.- Specified by:
resolves
in interfaceResolvingContext
- Parameters:
expression
- the expression for which to check if it is resolved- Returns:
true
if the expression is resolved within the context,false
if not
-
resolvedValueOf
public <R,E extends Expression<R>> R resolvedValueOf(E expression)
Description copied from interface:ResolvingContext
Retrieves the resolved value for the expression. This action can be completed, if the result of the given expression is already known within the context, or if the expression is a resolved expression itself.An
IllegalArgumentException
will be thrown, if the expression cannot be resolved within the context. Therefore it is mandatory to call theResolvingContext.resolves(Expression)
method first to check if the expression is resolved in the context.- Specified by:
resolvedValueOf
in interfaceResolvingContext
- Parameters:
expression
- the expression for which to retrieve the resolved value- Returns:
- the resolved value for the expression
-
put
public <R,E extends Expression<R>> void put(E key, R value)
Description copied from interface:EditableResolvingContext
Put a key and value in the resolving context. The key is usually an unresolved node and the value is the resolved version of this node- Specified by:
put
in interfaceEditableResolvingContext
- Parameters:
key
- the unresolved nodevalue
- the resolved version of the key node
-
-