public class CompositeOperandTypeChecker extends 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 String |
allowedSignatures |
protected CompositeOperandTypeChecker.Composition |
composition |
private SqlOperandCountRange |
range |
| Constructor and Description |
|---|
CompositeOperandTypeChecker(CompositeOperandTypeChecker.Composition composition,
com.google.common.collect.ImmutableList<? extends SqlOperandTypeChecker> allowedRules,
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.
|
String |
getAllowedSignatures(SqlOperator op,
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
ith operand is optional. |
private int |
maxMax(List<SqlOperandCountRange> ranges) |
private int |
minMin(List<SqlOperandCountRange> ranges) |
private final SqlOperandCountRange range
protected final com.google.common.collect.ImmutableList<? extends SqlOperandTypeChecker> allowedRules
protected final CompositeOperandTypeChecker.Composition composition
private final String allowedSignatures
CompositeOperandTypeChecker(CompositeOperandTypeChecker.Composition composition, com.google.common.collect.ImmutableList<? extends SqlOperandTypeChecker> allowedRules, @Nullable String allowedSignatures, @Nullable SqlOperandCountRange range)
public boolean isOptional(int i)
SqlOperandTypeCheckerith operand is optional.isOptional in interface SqlOperandTypeCheckerpublic com.google.common.collect.ImmutableList<? extends SqlOperandTypeChecker> getRules()
public SqlOperandTypeChecker.Consistency getConsistency()
SqlOperandTypeCheckergetConsistency in interface SqlOperandTypeCheckerpublic String getAllowedSignatures(SqlOperator op, String opName)
SqlOperandTypeCheckergetAllowedSignatures in interface SqlOperandTypeCheckerop - the operator being checkedopName - name to use for the operator in case of aliasingpublic SqlOperandCountRange getOperandCountRange()
getOperandCountRange in interface SqlOperandTypeCheckerprivate int minMin(List<SqlOperandCountRange> ranges)
private int maxMax(List<SqlOperandCountRange> ranges)
public boolean checkOperandTypes(SqlCallBinding callBinding, boolean throwOnFailure)
SqlOperandTypeCheckercheckOperandTypes in interface SqlOperandTypeCheckercallBinding - 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–2018 The Apache Software Foundation. All rights reserved.