public class CompositeOperandTypeChecker extends java.lang.Object implements SqlOperandTypeChecker
SqlOperandTypeChecker
rules to be
combined into one rule. For example, allowing an operand to be either string
or numeric could be done by:
CompositeOperandsTypeChecking newCompositeRule = new CompositeOperandsTypeChecking(Composition.OR, new SqlOperandTypeChecker[]{stringRule, numericRule});
Similarly a rule that would only allow a numeric literal can be done by:
CompositeOperandsTypeChecking newCompositeRule = new CompositeOperandsTypeChecking(Composition.AND, new SqlOperandTypeChecker[]{numericRule, literalRule});
Finally, creating a signature expecting a string for the first operand and a numeric for the second operand can be done by:
CompositeOperandsTypeChecking newCompositeRule = new CompositeOperandsTypeChecking(Composition.SEQUENCE, new SqlOperandTypeChecker[]{stringRule, numericRule});
For SEQUENCE composition, the rules must be instances of SqlSingleOperandTypeChecker, and signature generation is not supported. For AND composition, only the first rule is used for signature generation.
Modifier and Type | Class and Description |
---|---|
static class |
CompositeOperandTypeChecker.Composition
How operands are composed.
|
SqlOperandTypeChecker.Consistency
Modifier and Type | Field and Description |
---|---|
protected com.google.common.collect.ImmutableList<? extends SqlOperandTypeChecker> |
allowedRules |
private java.lang.String |
allowedSignatures |
protected CompositeOperandTypeChecker.Composition |
composition |
private SqlOperandCountRange |
range |
Constructor and Description |
---|
CompositeOperandTypeChecker(CompositeOperandTypeChecker.Composition composition,
com.google.common.collect.ImmutableList<? extends SqlOperandTypeChecker> allowedRules,
java.lang.String allowedSignatures,
SqlOperandCountRange range)
Package private.
|
Modifier and Type | Method and Description |
---|---|
private boolean |
check(SqlCallBinding callBinding) |
boolean |
checkOperandTypes(SqlCallBinding callBinding,
boolean throwOnFailure)
Checks the types of all operands to an operator call.
|
java.lang.String |
getAllowedSignatures(SqlOperator op,
java.lang.String opName)
Returns a string describing the allowed formal signatures of a call, e.g.
|
SqlOperandTypeChecker.Consistency |
getConsistency()
Returns the strategy for making the arguments have consistency types.
|
SqlOperandCountRange |
getOperandCountRange() |
com.google.common.collect.ImmutableList<? extends SqlOperandTypeChecker> |
getRules() |
boolean |
isOptional(int i)
Returns whether the
i th operand is optional. |
private int |
maxMax(java.util.List<SqlOperandCountRange> ranges) |
private int |
minMin(java.util.List<SqlOperandCountRange> ranges) |
private final SqlOperandCountRange range
protected final com.google.common.collect.ImmutableList<? extends SqlOperandTypeChecker> allowedRules
protected final CompositeOperandTypeChecker.Composition composition
private final java.lang.String allowedSignatures
CompositeOperandTypeChecker(CompositeOperandTypeChecker.Composition composition, com.google.common.collect.ImmutableList<? extends SqlOperandTypeChecker> allowedRules, @Nullable java.lang.String allowedSignatures, @Nullable SqlOperandCountRange range)
public boolean isOptional(int i)
SqlOperandTypeChecker
i
th operand is optional.isOptional
in interface SqlOperandTypeChecker
public com.google.common.collect.ImmutableList<? extends SqlOperandTypeChecker> getRules()
public SqlOperandTypeChecker.Consistency getConsistency()
SqlOperandTypeChecker
getConsistency
in interface SqlOperandTypeChecker
public java.lang.String getAllowedSignatures(SqlOperator op, java.lang.String opName)
SqlOperandTypeChecker
getAllowedSignatures
in interface SqlOperandTypeChecker
op
- the operator being checkedopName
- name to use for the operator in case of aliasingpublic SqlOperandCountRange getOperandCountRange()
getOperandCountRange
in interface SqlOperandTypeChecker
private int minMin(java.util.List<SqlOperandCountRange> ranges)
private int maxMax(java.util.List<SqlOperandCountRange> ranges)
public boolean checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure)
SqlOperandTypeChecker
checkOperandTypes
in interface SqlOperandTypeChecker
callBinding
- description of the call to be checkedthrowOnFailure
- whether to throw an exception if check fails
(otherwise returns false in that case)private boolean check(SqlCallBinding callBinding)
Copyright © 2012–2019 The Apache Software Foundation. All rights reserved.