| Modifier and Type | Class and Description |
|---|---|
static class |
SoyTypes.SoyTypeArithmeticOperator
Type resolver for all arithmetic operators (except plus operator).
|
static interface |
SoyTypes.SoyTypeBinaryOperator
A type resolver interface that can be passed into getSoyTypeForBinaryOperator method.
|
static class |
SoyTypes.SoyTypeComparisonOp
Type resolver for For <, >, <=, and >= operators.
|
static class |
SoyTypes.SoyTypeEqualComparisonOp
Type resolver for equal (==) and not equal (!=) operators.
|
static class |
SoyTypes.SoyTypePlusOperator
Type resolver for plus operators.
|
| Modifier and Type | Field and Description |
|---|---|
static SoyType |
NUMBER_TYPE
Shared constant for the 'number' type.
|
| Constructor and Description |
|---|
SoyTypes() |
| Modifier and Type | Method and Description |
|---|---|
static SoyType |
computeLowestCommonType(SoyTypeRegistry typeRegistry,
Collection<SoyType> types)
Compute the most specific type that is assignable from all types within a collection.
|
static SoyType |
computeLowestCommonType(SoyTypeRegistry typeRegistry,
SoyType t0,
SoyType t1)
Compute the most specific type that is assignable from both t0 and t1.
|
static com.google.common.base.Optional<SoyType> |
computeLowestCommonTypeArithmetic(SoyType t0,
SoyType t1)
Compute the most specific type that is assignable from both t0 and t1, taking into account
arithmetic promotions - that is, converting int to float if needed.
|
static SoyType |
getSoyTypeForBinaryOperator(SoyType t0,
SoyType t1,
SoyTypes.SoyTypeBinaryOperator operator)
Returns the
SoyType that should be the result of a binary operator. |
static boolean |
isNullable(SoyType type) |
static boolean |
isNumericOrUnknown(SoyType type) |
static boolean |
isNumericPrimitive(SoyType type)
Returns true if the input type is a numeric primitive type, such as int, float, proto enum, and
number.
|
static SoyType |
makeNullable(SoyType type) |
static SoyType |
removeNull(SoyType type) |
static SoyType |
tryRemoveNull(SoyType soyType)
If the type is nullable, makes it non-nullable.
|
public static final SoyType NUMBER_TYPE
public static boolean isNumericPrimitive(SoyType type)
public static SoyType tryRemoveNull(SoyType soyType)
If the type is the null type, then it returns the null type.
public static boolean isNullable(SoyType type)
public static boolean isNumericOrUnknown(SoyType type)
public static SoyType computeLowestCommonType(SoyTypeRegistry typeRegistry, SoyType t0, SoyType t1)
typeRegistry - Type registry.t0 - A type.t1 - Another type.public static SoyType computeLowestCommonType(SoyTypeRegistry typeRegistry, Collection<SoyType> types)
typeRegistry - Type registry.types - List of types.public static com.google.common.base.Optional<SoyType> computeLowestCommonTypeArithmetic(SoyType t0, SoyType t1)
t0 - A type.t1 - Another type.@Nullable public static SoyType getSoyTypeForBinaryOperator(SoyType t0, SoyType t1, SoyTypes.SoyTypeBinaryOperator operator)
SoyType that should be the result of a binary operator.
This method is mostly for handling UnionType instances. For primitive soy types, the
logic should be defined in the SoyTypeBinaryOperator. Recursion is used for collecting
all possible combinations if any of the operands is UnionType. This method will return
null if any of the combinations is incompatible (the operator returns null).