@Internal public final class InputTypeStrategies extends Object
InputTypeStrategy
,
ArgumentTypeStrategy
Modifier and Type | Field and Description |
---|---|
static AnyArgumentTypeStrategy |
ANY
Strategy for an argument that can be of any type.
|
static ArgumentTypeStrategy |
COMMON_ARG
Argument type strategy that checks and casts for a common, least restrictive type of all
arguments.
|
static ArgumentTypeStrategy |
COMMON_ARG_NULLABLE
Argument type strategy that checks and casts for a common, least restrictive type of all
arguments.
|
static ArgumentTypeStrategy |
COMPOSITE
Strategy that checks that the argument has a composite type.
|
static ArgumentTypeStrategy |
ITEM_AT_INDEX |
static LiteralArgumentTypeStrategy |
LITERAL
Strategy that checks if an argument is a literal.
|
static LiteralArgumentTypeStrategy |
LITERAL_OR_NULL
Strategy that checks if an argument is a literal or NULL.
|
static InputTypeStrategy |
NO_ARGS
Strategy that does not expect any arguments.
|
static OutputArgumentTypeStrategy |
OUTPUT_IF_NULL
Strategy for inferring an unknown argument type from the function's output
DataType
if available. |
static TypeLiteralArgumentTypeStrategy |
TYPE_LITERAL
Strategy that checks if an argument is a type literal.
|
static WildcardInputTypeStrategy |
WILDCARD
Strategy that does not perform any modification or validation of the input.
|
Modifier and Type | Method and Description |
---|---|
static AndArgumentTypeStrategy |
and(ArgumentTypeStrategy... strategies)
Strategy for a conjunction of multiple
ArgumentTypeStrategy s into one like f(NUMERIC && LITERAL) . |
static InputTypeStrategy |
commonArrayType(int count)
An
InputTypeStrategy that expects count arguments that have a common array
type. |
static InputTypeStrategy |
commonMapType(int minCount)
An
InputTypeStrategy that expects minCount arguments that have a common map
type. |
static InputTypeStrategy |
commonMultipleArrayType(int minCount)
An
InputTypeStrategy that expects minCount arguments that have a common array
type. |
static InputTypeStrategy |
commonType(int count)
An
InputTypeStrategy that expects count arguments that have a common type. |
static InputTypeStrategy |
comparable(ConstantArgumentCount argumentCount,
StructuredType.StructuredComparison requiredComparison)
Strategy that checks all types are comparable with each other.
|
static SubsequenceInputTypeStrategy.SubsequenceStrategyBuilder |
compositeSequence()
An strategy that lets you apply other strategies for subsequences of the actual arguments.
|
static ConstraintArgumentTypeStrategy |
constraint(String constraintMessage,
Predicate<List<DataType>> evaluator)
Strategy for an argument that must fulfill a given constraint.
|
static ExplicitArgumentTypeStrategy |
explicit(DataType expectedDataType)
Strategy for an argument that corresponds to an explicitly defined type casting.
|
static InputTypeStrategy |
explicitSequence(DataType... expectedDataTypes)
Strategy for a function signature of explicitly defined types like
f(STRING, INT) . |
static InputTypeStrategy |
explicitSequence(String[] argumentNames,
DataType[] expectedDataTypes)
Strategy for a named function signature of explicitly defined types like
f(s STRING, i
INT) . |
static FamilyArgumentTypeStrategy |
logical(LogicalTypeFamily expectedFamily)
Strategy for an argument that corresponds to a given
LogicalTypeFamily . |
static FamilyArgumentTypeStrategy |
logical(LogicalTypeFamily expectedFamily,
boolean expectedNullability)
Strategy for an argument that corresponds to a given
LogicalTypeFamily and
nullability. |
static RootArgumentTypeStrategy |
logical(LogicalTypeRoot expectedRoot)
Strategy for an argument that corresponds to a given
LogicalTypeRoot . |
static RootArgumentTypeStrategy |
logical(LogicalTypeRoot expectedRoot,
boolean expectedNullability)
Strategy for an argument that corresponds to a given
LogicalTypeRoot and nullability. |
static OrArgumentTypeStrategy |
or(ArgumentTypeStrategy... strategies)
Strategy for a disjunction of multiple
ArgumentTypeStrategy s into one like f(NUMERIC || STRING) . |
static InputTypeStrategy |
or(InputTypeStrategy... strategies)
Strategy for a disjunction of multiple
InputTypeStrategy s into one like f(NUMERIC) || f(STRING) . |
static InputTypeStrategy |
repeatingSequence(ArgumentTypeStrategy... strategies)
Arbitrarily often repeating sequence of argument type strategies.
|
static InputTypeStrategy |
sequence(ArgumentTypeStrategy... strategies)
Strategy for a function signature like
f(STRING, NUMERIC) using a sequence of ArgumentTypeStrategy s. |
static InputTypeStrategy |
sequence(List<String> argumentNames,
List<ArgumentTypeStrategy> strategies)
Strategy for a named function signature like
f(s STRING, n NUMERIC) using a sequence
of ArgumentTypeStrategy s. |
static InputTypeStrategy |
sequence(String[] argumentNames,
ArgumentTypeStrategy[] strategies)
Strategy for a named function signature like
f(s STRING, n NUMERIC) using a sequence
of ArgumentTypeStrategy s. |
static SymbolArgumentTypeStrategy<?> |
symbol(Class<? extends Enum<? extends TableSymbol>> clazz)
Strategy for a symbol argument of a specific
TableSymbol enum. |
static <T extends Enum<? extends TableSymbol>> |
symbol(T firstAllowedVariant,
T... otherAllowedVariants)
Strategy for a symbol argument of a specific
TableSymbol enum, with value being one
of the provided variants. |
static InputTypeStrategy |
varyingSequence(ArgumentTypeStrategy... strategies)
Strategy for a varying function signature like
f(INT, STRING, NUMERIC...) using a
sequence of ArgumentTypeStrategy s. |
static InputTypeStrategy |
varyingSequence(String[] argumentNames,
ArgumentTypeStrategy[] strategies)
Strategy for a varying named function signature like
f(i INT, str STRING, num
NUMERIC...) using a sequence of ArgumentTypeStrategy s. |
static InputTypeStrategy |
wildcardWithCount(ArgumentCount argumentCount)
Strategy that does not perform any modification or validation of the input.
|
public static final WildcardInputTypeStrategy WILDCARD
public static final InputTypeStrategy NO_ARGS
public static final OutputArgumentTypeStrategy OUTPUT_IF_NULL
DataType
if available.public static final AnyArgumentTypeStrategy ANY
public static final LiteralArgumentTypeStrategy LITERAL
public static final LiteralArgumentTypeStrategy LITERAL_OR_NULL
public static final TypeLiteralArgumentTypeStrategy TYPE_LITERAL
public static final ArgumentTypeStrategy COMPOSITE
public static final ArgumentTypeStrategy COMMON_ARG
public static final ArgumentTypeStrategy COMMON_ARG_NULLABLE
public static final ArgumentTypeStrategy ITEM_AT_INDEX
ItemAtIndexArgumentTypeStrategy
public static InputTypeStrategy sequence(ArgumentTypeStrategy... strategies)
f(STRING, NUMERIC)
using a sequence of ArgumentTypeStrategy
s.public static InputTypeStrategy sequence(String[] argumentNames, ArgumentTypeStrategy[] strategies)
f(s STRING, n NUMERIC)
using a sequence
of ArgumentTypeStrategy
s.public static InputTypeStrategy sequence(List<String> argumentNames, List<ArgumentTypeStrategy> strategies)
f(s STRING, n NUMERIC)
using a sequence
of ArgumentTypeStrategy
s.public static InputTypeStrategy varyingSequence(ArgumentTypeStrategy... strategies)
f(INT, STRING, NUMERIC...)
using a
sequence of ArgumentTypeStrategy
s. The first n - 1 arguments must be constant. The
n-th argument can occur 0, 1, or more times.public static InputTypeStrategy varyingSequence(String[] argumentNames, ArgumentTypeStrategy[] strategies)
f(i INT, str STRING, num
NUMERIC...)
using a sequence of ArgumentTypeStrategy
s. The first n - 1 arguments
must be constant. The n-th argument can occur 0, 1, or more times.public static InputTypeStrategy repeatingSequence(ArgumentTypeStrategy... strategies)
public static InputTypeStrategy explicitSequence(DataType... expectedDataTypes)
f(STRING, INT)
.
Implicit casts will be inserted if possible.
This is equivalent to using sequence(ArgumentTypeStrategy...)
and explicit(DataType)
.
public static InputTypeStrategy explicitSequence(String[] argumentNames, DataType[] expectedDataTypes)
f(s STRING, i
INT)
. Implicit casts will be inserted if possible.
This is equivalent to using sequence(String[], ArgumentTypeStrategy[])
and explicit(DataType)
.
public static SubsequenceInputTypeStrategy.SubsequenceStrategyBuilder compositeSequence()
The sequence(ArgumentTypeStrategy...)
should be preferred in most of the cases.
Use this strategy only if you need to apply a common logic to a subsequence of the arguments.
public static InputTypeStrategy or(InputTypeStrategy... strategies)
InputTypeStrategy
s into one like f(NUMERIC) || f(STRING)
.
This strategy aims to infer a list of types that are equal to the input types (to prevent unnecessary casting) or (if this is not possible) the first more specific, casted types.
public static InputTypeStrategy wildcardWithCount(ArgumentCount argumentCount)
public static InputTypeStrategy comparable(ConstantArgumentCount argumentCount, StructuredType.StructuredComparison requiredComparison)
public static ExplicitArgumentTypeStrategy explicit(DataType expectedDataType)
public static RootArgumentTypeStrategy logical(LogicalTypeRoot expectedRoot)
LogicalTypeRoot
. Implicit casts
will be inserted if possible.public static RootArgumentTypeStrategy logical(LogicalTypeRoot expectedRoot, boolean expectedNullability)
LogicalTypeRoot
and nullability.
Implicit casts will be inserted if possible.public static FamilyArgumentTypeStrategy logical(LogicalTypeFamily expectedFamily)
LogicalTypeFamily
. Implicit
casts will be inserted if possible.public static FamilyArgumentTypeStrategy logical(LogicalTypeFamily expectedFamily, boolean expectedNullability)
LogicalTypeFamily
and
nullability. Implicit casts will be inserted if possible.public static ConstraintArgumentTypeStrategy constraint(String constraintMessage, Predicate<List<DataType>> evaluator)
public static AndArgumentTypeStrategy and(ArgumentTypeStrategy... strategies)
ArgumentTypeStrategy
s into one like f(NUMERIC && LITERAL)
.
Some ArgumentTypeStrategy
s cannot contribute an inferred type that is different
from the input type (e.g. 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 the first more specific, casted type or (if this is not
possible) a type that has been inferred from all ArgumentTypeStrategy
s.
public static OrArgumentTypeStrategy or(ArgumentTypeStrategy... strategies)
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. 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.
public static SymbolArgumentTypeStrategy<?> symbol(Class<? extends Enum<? extends TableSymbol>> clazz)
TableSymbol
enum.
A symbol is implied to be a literal argument.
@SafeVarargs public static <T extends Enum<? extends TableSymbol>> SymbolArgumentTypeStrategy<T> symbol(T firstAllowedVariant, T... otherAllowedVariants)
TableSymbol
enum, with value being one
of the provided variants.
A symbol is implied to be a literal argument.
public static InputTypeStrategy commonType(int count)
InputTypeStrategy
that expects count
arguments that have a common type.public static InputTypeStrategy commonArrayType(int count)
InputTypeStrategy
that expects count
arguments that have a common array
type.public static InputTypeStrategy commonMultipleArrayType(int minCount)
InputTypeStrategy
that expects minCount
arguments that have a common array
type.public static InputTypeStrategy commonMapType(int minCount)
InputTypeStrategy
that expects minCount
arguments that have a common map
type.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.