@Internal public final class OrArgumentTypeStrategy extends Object implements ArgumentTypeStrategy
ArgumentTypeStrategy
s into one like f(NUMERIC || STRING)
.
Some ArgumentTypeStrategy
s cannot contribute an inferred type that is different from
the input type (e.g. InputTypeStrategies.LITERAL
). Therefore, the order f(X || Y)
or f(Y || X)
matters as it defines the precedence in case the result must be casted to a
more specific type.
This strategy aims to infer a type that is equal to the input type (to prevent unnecessary casting) or (if this is not possible) the first more specific, casted type.
Constructor and Description |
---|
OrArgumentTypeStrategy(List<? extends ArgumentTypeStrategy> argumentStrategies) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
Signature.Argument |
getExpectedArgument(FunctionDefinition functionDefinition,
int argumentPos)
Returns a summary of the function's expected argument at
argumentPos . |
int |
hashCode() |
Optional<DataType> |
inferArgumentType(CallContext callContext,
int argumentPos,
boolean throwOnFailure)
Main logic for inferring and validating an argument.
|
public OrArgumentTypeStrategy(List<? extends ArgumentTypeStrategy> argumentStrategies)
public Optional<DataType> inferArgumentType(CallContext callContext, int argumentPos, boolean throwOnFailure)
ArgumentTypeStrategy
CallContext.getArgumentDataTypes()
at argumentPos
, a casting operation can be inserted. An empty result means that the
given input type could not be inferred.inferArgumentType
in interface ArgumentTypeStrategy
callContext
- provides details about the function callargumentPos
- argument index in the CallContext
throwOnFailure
- whether this function is allowed to throw an ValidationException
with a meaningful exception in case the inference is not successful
or if this function should simply return an empty result.CallContext.newValidationError(String, Object...)
public Signature.Argument getExpectedArgument(FunctionDefinition functionDefinition, int argumentPos)
ArgumentTypeStrategy
argumentPos
.getExpectedArgument
in interface ArgumentTypeStrategy
functionDefinition
- the function definition that defines the function currently being
called.argumentPos
- the position within the function call for which the signature should be
retrievedCopyright © 2014–2024 The Apache Software Foundation. All rights reserved.