Package org.qubership.atp.dataset.macros
Class EvalContextImpl
java.lang.Object
org.qubership.atp.dataset.macros.EvalContextImpl
- All Implemented Interfaces:
EvaluationContext
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Cacheprotected final MacroRegistrystatic final Comparator<EvalContextImpl> protected final AliasWrapperService -
Constructor Summary
ConstructorsConstructorDescriptionEvalContextImpl(EvalContextImpl parent, MacroRegistry registry, AliasWrapperService wrapperService, Cache cache, DataSetList dsl, DataSet ds, boolean parentIsStrict, List<Attribute> pathFromParent, Attribute targetAttrFromParent) Contains state of evaluation plus all used resources. -
Method Summary
Modifier and TypeMethodDescriptionprotected EvalContextImplcreateChild(DataSetList dsl, DataSet ds, boolean parentIsStrict, List<Attribute> pathFromParent, Attribute targetAttrFromParent) protected EvalContextImplcreateChild(OverlapItem.Reachable source, Parameter target) booleanEvaluates text using this context.protected Stringevaluate(String inputText, MacroCacheKey cacheKey) Evaluates parameter using this context.evaluate(OverlapItem.Reachable source, Parameter target, String value) Finds context to evaluate parameter in.<O> OexecuteInAnyContext(Iterator<? extends EvaluationContext> of, MacroContext.ContextedTask<O> toExecute) ExecutesMacroContext.ContextedTaskin a context chain.getDs()getDsl()May be empty.getRoot()Returns root context of a context chain.May not be empty.inthashCode()relativizePathFromSharedToThis(EvaluationContext shared, List<RefArg<Attribute>> attrArgs) When you are searching for params in shared context by using refs, defined in this context, you should relativize attribute path like if param was defined in shared context.voidresolveArguments(List<? extends RefArg<?>> args) toString()
-
Field Details
-
SAME_NON_STRICT
-
registry
-
wrapperService
-
cache
-
-
Constructor Details
-
EvalContextImpl
public EvalContextImpl(@Nullable EvalContextImpl parent, @Nonnull MacroRegistry registry, @Nonnull AliasWrapperService wrapperService, @Nonnull Cache cache, @Nonnull DataSetList dsl, @Nonnull DataSet ds, boolean parentIsStrict, @Nonnull List<Attribute> pathFromParent, @Nullable Attribute targetAttrFromParent) Contains state of evaluation plus all used resources.
-
-
Method Details
-
getParent
- Specified by:
getParentin interfaceEvaluationContext
-
getDsl
- Specified by:
getDslin interfaceEvaluationContext
-
getDs
- Specified by:
getDsin interfaceEvaluationContext
-
getRoot
Description copied from interface:EvaluationContextReturns root context of a context chain.- Specified by:
getRootin interfaceEvaluationContext
-
evaluate
@Nonnull public String evaluate(@Nonnull OverlapItem.Reachable source, @Nonnull Parameter target, @Nonnull String value) throws CtxEvalException Description copied from interface:EvaluationContextFinds context to evaluate parameter in. Evaluates parameter using found context.- Specified by:
evaluatein interfaceEvaluationContext- Parameters:
target- issource.getParameter().get(). Ensure that it exists first.value- issource.getParameter().get().getValue().get(). Ensure that it exists first.- Throws:
CtxEvalException
-
evaluate
Description copied from interface:EvaluationContextEvaluates text using this context. UseEvaluationContext.evaluate(Parameter, String)when possible!- Specified by:
evaluatein interfaceEvaluationContext- Parameters:
inputText- text to evaluate.- Throws:
CtxEvalException
-
evaluate
@Nonnull protected String evaluate(@Nonnull String inputText, @Nonnull MacroCacheKey cacheKey) throws CtxEvalException - Throws:
CtxEvalException
-
evaluate
@Nonnull public String evaluate(@Nonnull Parameter parameter, @Nonnull String value) throws CtxEvalException Description copied from interface:EvaluationContextEvaluates parameter using this context. UseEvaluationContext.evaluate(OverlapItem.Reachable, Parameter, String)when possible!- Specified by:
evaluatein interfaceEvaluationContext- Parameters:
parameter- to evaluate.value- isparameter.getValue().get(). Ensure that it is exists first.- Throws:
CtxEvalException
-
createChild
@Nonnull protected EvalContextImpl createChild(@Nonnull OverlapItem.Reachable source, @Nonnull Parameter target) -
createChild
@Nonnull protected EvalContextImpl createChild(@Nonnull DataSetList dsl, @Nonnull DataSet ds, boolean parentIsStrict, @Nonnull List<Attribute> pathFromParent, @Nonnull Attribute targetAttrFromParent) -
executeInAnyContext
@Nonnull public <O> O executeInAnyContext(@Nonnull Iterator<? extends EvaluationContext> of, @Nonnull MacroContext.ContextedTask<O> toExecute) throws CtxEvalException ExecutesMacroContext.ContextedTaskin a context chain. Starting context is the provided one (current). Going upper through callers contexts if the task failed with an exception. Returns first valid task result.- Specified by:
executeInAnyContextin interfaceEvaluationContext- Parameters:
of- typically isEvaluationContext.getStrictContexts().- Throws:
CtxEvalException- if args are not resolved or task failed with an exception in all possible contexts.
-
resolveArguments
- Specified by:
resolveArgumentsin interfaceEvaluationContext- Throws:
Exception
-
toString
-
equals
-
hashCode
public int hashCode() -
getStrictContexts
May not be empty. Returned contexts are relative andEvaluationContext.relativizePathFromSharedToThis(EvaluationContext, List)should be used for each of them.- Specified by:
getStrictContextsin interfaceEvaluationContext- Returns:
- callers plus this.
-
getNonStrictContexts
Description copied from interface:EvaluationContextMay be empty. Returned contexts are not relative andEvaluationContext.relativizePathFromSharedToThis(EvaluationContext, List)should not be used for each of them. Used when no one string context fits to your needs.- Specified by:
getNonStrictContextsin interfaceEvaluationContext- Returns:
- additional contexts.
-