Class DefaultParameterResolver
- java.lang.Object
-
- de.gebit.integrity.parameter.resolving.DefaultParameterResolver
-
- All Implemented Interfaces:
ParameterResolver
public class DefaultParameterResolver extends java.lang.Object implements ParameterResolver
The default implementation of a parameter resolver.- Author:
- Rene Schneider - initial API and implementation
-
-
Field Summary
Fields Modifier and Type Field Description protected StandardOperationProcessor
standardOperationProcessor
The processor for standard operations.protected VariableManager
variableManager
The variable manager to use.protected WrapperFactory
wrapperFactory
The wrapper factory to use.
-
Constructor Summary
Constructors Constructor Description DefaultParameterResolver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.Object>
createExpectedResultMap(Test aTest, boolean anIncludeArbitraryResultFlag)
Returns a map of named results as expected by the givenTest
.java.util.Map<java.lang.String,java.lang.Object>
createParameterMap(Call aCall, boolean anIncludeArbitraryParametersFlag, UnresolvableVariableHandling anUnresolvableVariableHandlingPolicy)
Returns a map mapping a parameter name to a value, exploring a givenCall
to determine the valid parameters.java.util.Map<java.lang.String,java.lang.Object>
createParameterMap(TableTest aTableTest, TableTestRow aTableTestRow, TableTestParameterResolveMethod aResolveMethod, boolean anIncludeArbitraryParametersFlag, UnresolvableVariableHandling anUnresolvableVariableHandlingPolicy)
Returns a map mapping a parameter name to a value, exploring a given row of aTableTest
to determine the valid parameters.java.util.Map<java.lang.String,java.lang.Object>
createParameterMap(Test aTest, boolean anIncludeArbitraryParametersFlag, UnresolvableVariableHandling anUnresolvableVariableHandlingPolicy)
Returns a map mapping a parameter name to a value, exploring a givenTest
to determine the valid parameters.java.util.Map<java.lang.String,java.lang.Object>
createParameterMap(java.util.List<Parameter> someParameters, boolean anIncludeArbitraryParametersFlag, UnresolvableVariableHandling anUnresolvableVariableHandlingPolicy)
Returns a map mapping a parameter name to a value, using a list ofParameter
instances to determine the valid parameters.boolean
isSafelyStaticallyResolvable(ValueOrEnumValueOrOperationCollection aValue, VariantDefinition aVariant)
Determines whether the givenValueOrEnumValueOrOperationCollection
is safely resolvable to a value in a static way, that is, not requiring a current execution context.boolean
isSafelyStaticallyResolvable(ValueOrEnumValueOrOperation aValue, VariantDefinition aVariant)
Determines whether the givenValueOrEnumValueOrOperation
is safely resolvable to a value in a static way, that is, not requiring a current execution context.java.lang.Object
resolveParameterValue(ValueOrEnumValueOrOperationCollection aValueCollection, UnresolvableVariableHandling anUnresolvableVariableHandlingPolicy)
Resolves the givenValueOrEnumValueOrOperationCollection
, using the variable map given.java.lang.Object
resolveSingleParameterValue(ValueOrEnumValueOrOperation aValue, UnresolvableVariableHandling anUnresolvableVariableHandlingPolicy)
Resolves the givenValueOrEnumValueOrOperation
, using the variable map given.java.lang.Object
resolveStatically(ConstantDefinition aConstant, VariantDefinition aVariant)
Resolves a constant definition to its defined value, which may depend on the active variant.java.lang.Object
resolveStatically(ValueOrEnumValueOrOperationCollection aValue, VariantDefinition aVariant)
Resolves aValueOrEnumValueOrOperationCollection
to its actual value statically, that is, not requiring a current test execution context.java.lang.Object
resolveStatically(ValueOrEnumValueOrOperation aValue, VariantDefinition aVariant)
Resolves aValueOrEnumValueOrOperation
to its actual value statically, that is, not requiring a current test execution context.java.lang.Object
resolveStatically(VariableOrConstantEntity anEntity, VariantDefinition aVariant)
Resolves a variable (recursively, if necessary) to its actual value.java.lang.Object
resolveStatically(Variable aVariable, VariantDefinition aVariant)
Resolves a variable (recursively, if necessary) to its actual value.
-
-
-
Field Detail
-
wrapperFactory
@Inject(optional=true) protected WrapperFactory wrapperFactory
The wrapper factory to use.
-
variableManager
@Inject(optional=true) protected VariableManager variableManager
The variable manager to use.
-
standardOperationProcessor
@Inject protected StandardOperationProcessor standardOperationProcessor
The processor for standard operations.
-
-
Method Detail
-
createParameterMap
public java.util.Map<java.lang.String,java.lang.Object> createParameterMap(Test aTest, boolean anIncludeArbitraryParametersFlag, UnresolvableVariableHandling anUnresolvableVariableHandlingPolicy) throws java.lang.ClassNotFoundException, UnexecutableException, java.lang.InstantiationException
Description copied from interface:ParameterResolver
Returns a map mapping a parameter name to a value, exploring a givenTest
to determine the valid parameters. Parameters that contain references to variables will be resolved if the variable map is provided, but no type conversions will be done.- Specified by:
createParameterMap
in interfaceParameterResolver
- Parameters:
aTest
- the testanIncludeArbitraryParametersFlag
- whether arbitrary parameters should be determined and included as wellanUnresolvableVariableHandlingPolicy
- Defines the policy how unresolvable variable references (no variable given or noVariableManager
available) shall be treated- Returns:
- a map with a String to value mapping
- Throws:
java.lang.ClassNotFoundException
UnexecutableException
java.lang.InstantiationException
-
createParameterMap
public java.util.Map<java.lang.String,java.lang.Object> createParameterMap(Call aCall, boolean anIncludeArbitraryParametersFlag, UnresolvableVariableHandling anUnresolvableVariableHandlingPolicy) throws java.lang.ClassNotFoundException, UnexecutableException, java.lang.InstantiationException
Description copied from interface:ParameterResolver
Returns a map mapping a parameter name to a value, exploring a givenCall
to determine the valid parameters. Parameters that contain references to variables will be resolved if the variable map is provided, but no type conversions will be done.- Specified by:
createParameterMap
in interfaceParameterResolver
- Parameters:
aCall
- the callanIncludeArbitraryParametersFlag
- whether arbitrary parameters should be determined and included as wellanUnresolvableVariableHandlingPolicy
- Defines the policy how unresolvable variable references (no variable given or noVariableManager
available) shall be treated- Returns:
- a map with a String to value mapping
- Throws:
java.lang.ClassNotFoundException
UnexecutableException
java.lang.InstantiationException
-
createParameterMap
public java.util.Map<java.lang.String,java.lang.Object> createParameterMap(TableTest aTableTest, TableTestRow aTableTestRow, TableTestParameterResolveMethod aResolveMethod, boolean anIncludeArbitraryParametersFlag, UnresolvableVariableHandling anUnresolvableVariableHandlingPolicy) throws java.lang.ClassNotFoundException, UnexecutableException, java.lang.InstantiationException
Description copied from interface:ParameterResolver
Returns a map mapping a parameter name to a value, exploring a given row of aTableTest
to determine the valid parameters. Parameters that contain operations and/or references to variables will be resolved if the variable map is provided, but no type conversions will be done.- Specified by:
createParameterMap
in interfaceParameterResolver
- Parameters:
aTableTest
- the table testaTableTestRow
- the row of the testaResolveMethod
- specifies the kind of params to be resolved (null =TableTestParameterResolveMethod.COMBINED
)anIncludeArbitraryParametersFlag
- whether arbitrary parameters should be determined and included as wellanUnresolvableVariableHandlingPolicy
- Defines the policy how unresolvable variable references (no variable given or noVariableManager
available) shall be treated- Returns:
- a map with a String to value mapping
- Throws:
java.lang.ClassNotFoundException
UnexecutableException
java.lang.InstantiationException
-
createParameterMap
public java.util.Map<java.lang.String,java.lang.Object> createParameterMap(java.util.List<Parameter> someParameters, boolean anIncludeArbitraryParametersFlag, UnresolvableVariableHandling anUnresolvableVariableHandlingPolicy) throws java.lang.ClassNotFoundException, UnexecutableException, java.lang.InstantiationException
Description copied from interface:ParameterResolver
Returns a map mapping a parameter name to a value, using a list ofParameter
instances to determine the valid parameters. Parameters that contain operations or references to variables will be resolved if the variable map is provided, but no type conversions will be done.- Specified by:
createParameterMap
in interfaceParameterResolver
- Parameters:
someParameters
- the parametersanIncludeArbitraryParametersFlag
- whether arbitrary parameters should be determined and included as wellanUnresolvableVariableHandlingPolicy
- Defines the policy how unresolvable variable references (no variable given or noVariableManager
available) shall be treated- Returns:
- a map with a String to value mapping
- Throws:
java.lang.ClassNotFoundException
UnexecutableException
java.lang.InstantiationException
-
resolveParameterValue
public java.lang.Object resolveParameterValue(ValueOrEnumValueOrOperationCollection aValueCollection, UnresolvableVariableHandling anUnresolvableVariableHandlingPolicy) throws UnexecutableException, java.lang.InstantiationException, java.lang.ClassNotFoundException
Description copied from interface:ParameterResolver
Resolves the givenValueOrEnumValueOrOperationCollection
, using the variable map given. Resolving only attempts to execute any operations and replace variable references with the current variable value, but does NOT convert the values to any other target type.- Specified by:
resolveParameterValue
in interfaceParameterResolver
- Parameters:
aValueCollection
- the value collection to resolveanUnresolvableVariableHandlingPolicy
- Defines the policy how unresolvable variable references (no variable given or noVariableManager
available) shall be treated- Returns:
- the resolved value
- Throws:
UnexecutableException
java.lang.InstantiationException
java.lang.ClassNotFoundException
-
resolveSingleParameterValue
public java.lang.Object resolveSingleParameterValue(ValueOrEnumValueOrOperation aValue, UnresolvableVariableHandling anUnresolvableVariableHandlingPolicy) throws UnexecutableException, java.lang.InstantiationException, java.lang.ClassNotFoundException
Description copied from interface:ParameterResolver
Resolves the givenValueOrEnumValueOrOperation
, using the variable map given. Resolving only attempts to execute any operations and replace variable references with the current variable value, but does NOT convert the values to any other target type.- Specified by:
resolveSingleParameterValue
in interfaceParameterResolver
- Parameters:
aValue
- the value to resolveanUnresolvableVariableHandlingPolicy
- Defines the policy how unresolvable variable references (no variable given or noVariableManager
available) shall be treated- Returns:
- the resolved value
- Throws:
UnexecutableException
java.lang.InstantiationException
java.lang.ClassNotFoundException
-
resolveStatically
public java.lang.Object resolveStatically(Variable aVariable, VariantDefinition aVariant) throws java.lang.ClassNotFoundException, java.lang.InstantiationException, UnexecutableException
Description copied from interface:ParameterResolver
Resolves a variable (recursively, if necessary) to its actual value. Since this static method doesn't have access to the actual variable store of a test runner instance, the resolving can only be successful in cases of variables with initial value (giving that value) or constants.- Specified by:
resolveStatically
in interfaceParameterResolver
- Parameters:
aVariable
- the variable to resolveaVariant
- the active variant- Returns:
- the result, or null if none was found
- Throws:
java.lang.ClassNotFoundException
java.lang.InstantiationException
UnexecutableException
-
resolveStatically
public java.lang.Object resolveStatically(VariableOrConstantEntity anEntity, VariantDefinition aVariant) throws java.lang.ClassNotFoundException, java.lang.InstantiationException, UnexecutableException
Description copied from interface:ParameterResolver
Resolves a variable (recursively, if necessary) to its actual value. Since this static method doesn't have access to the actual variable store of a test runner instance, the resolving can only be successful in cases of variables with initial value (giving that value) or constants.- Specified by:
resolveStatically
in interfaceParameterResolver
- Parameters:
anEntity
- the entity to resolveaVariant
- the active variant- Returns:
- the result, or null if none was found
- Throws:
java.lang.ClassNotFoundException
java.lang.InstantiationException
UnexecutableException
-
resolveStatically
public java.lang.Object resolveStatically(ValueOrEnumValueOrOperation aValue, VariantDefinition aVariant) throws UnexecutableException, java.lang.ClassNotFoundException, java.lang.InstantiationException
Description copied from interface:ParameterResolver
Resolves aValueOrEnumValueOrOperation
to its actual value statically, that is, not requiring a current test execution context.- Specified by:
resolveStatically
in interfaceParameterResolver
- Parameters:
aValue
- the entity to resolveaVariant
- the variant in use- Returns:
- the result value
- Throws:
UnexecutableException
java.lang.ClassNotFoundException
java.lang.InstantiationException
-
resolveStatically
public java.lang.Object resolveStatically(ValueOrEnumValueOrOperationCollection aValue, VariantDefinition aVariant) throws UnexecutableException, java.lang.ClassNotFoundException, java.lang.InstantiationException
Description copied from interface:ParameterResolver
Resolves aValueOrEnumValueOrOperationCollection
to its actual value statically, that is, not requiring a current test execution context.- Specified by:
resolveStatically
in interfaceParameterResolver
- Parameters:
aValue
- the entity to resolveaVariant
- the variant in use- Returns:
- the result value
- Throws:
UnexecutableException
java.lang.ClassNotFoundException
java.lang.InstantiationException
-
isSafelyStaticallyResolvable
public boolean isSafelyStaticallyResolvable(ValueOrEnumValueOrOperationCollection aValue, VariantDefinition aVariant)
Description copied from interface:ParameterResolver
Determines whether the givenValueOrEnumValueOrOperationCollection
is safely resolvable to a value in a static way, that is, not requiring a current execution context. "Safely" means that the resolved value is guaranteed not to change during runtime.- Specified by:
isSafelyStaticallyResolvable
in interfaceParameterResolver
- Parameters:
aValue
- the value to testaVariant
- the variant to assume- Returns:
- true if the value is safely resolvable, false otherwise
-
isSafelyStaticallyResolvable
public boolean isSafelyStaticallyResolvable(ValueOrEnumValueOrOperation aValue, VariantDefinition aVariant)
Description copied from interface:ParameterResolver
Determines whether the givenValueOrEnumValueOrOperation
is safely resolvable to a value in a static way, that is, not requiring a current execution context. "Safely" means that the resolved value is guaranteed not to change during runtime.- Specified by:
isSafelyStaticallyResolvable
in interfaceParameterResolver
- Parameters:
aValue
- the value to testaVariant
- the variant to assume- Returns:
- true if the value is safely resolvable, false otherwise
-
resolveStatically
public java.lang.Object resolveStatically(ConstantDefinition aConstant, VariantDefinition aVariant) throws UnexecutableException, java.lang.ClassNotFoundException, java.lang.InstantiationException
Description copied from interface:ParameterResolver
Resolves a constant definition to its defined value, which may depend on the active variant.- Specified by:
resolveStatically
in interfaceParameterResolver
- Parameters:
aConstant
- the constant to resolveaVariant
- the active variant- Returns:
- the result, or null if none is defined for the constant
- Throws:
UnexecutableException
java.lang.ClassNotFoundException
java.lang.InstantiationException
-
createExpectedResultMap
public java.util.Map<java.lang.String,java.lang.Object> createExpectedResultMap(Test aTest, boolean anIncludeArbitraryResultFlag)
Description copied from interface:ParameterResolver
Returns a map of named results as expected by the givenTest
. The Map will connect result names to actual values. Does not support variable resolving!- Specified by:
createExpectedResultMap
in interfaceParameterResolver
- Parameters:
aTest
- the testanIncludeArbitraryResultFlag
- whether arbitrary results shall be included- Returns:
- a map of Strings to values
-
-