Search in sources :

Example 1 with ParameterTypeSignature

use of io.crate.types.ParameterTypeSignature in project crate by crate.

the class SignatureBinder method applyBoundVariables.

private static TypeSignature applyBoundVariables(TypeSignature typeSignature, BoundVariables boundVariables) {
    String baseType = typeSignature.getBaseTypeName();
    if (boundVariables.containsTypeVariable(baseType)) {
        if (typeSignature.getParameters().isEmpty() == false) {
            throw new IllegalStateException("Type parameters cannot have parameters");
        }
        var boundTS = boundVariables.getTypeVariable(baseType).getTypeSignature();
        if (typeSignature instanceof ParameterTypeSignature) {
            return new ParameterTypeSignature(((ParameterTypeSignature) typeSignature).parameterName(), boundTS);
        }
        return boundTS;
    }
    List<TypeSignature> parameters = Lists2.map(typeSignature.getParameters(), typeSignatureParameter -> applyBoundVariables(typeSignatureParameter, boundVariables));
    if (typeSignature instanceof ParameterTypeSignature) {
        return new ParameterTypeSignature(((ParameterTypeSignature) typeSignature).parameterName(), new TypeSignature(baseType, parameters));
    }
    return new TypeSignature(baseType, parameters);
}
Also used : TypeSignature(io.crate.types.TypeSignature) ParameterTypeSignature(io.crate.types.ParameterTypeSignature) ParameterTypeSignature(io.crate.types.ParameterTypeSignature)

Aggregations

ParameterTypeSignature (io.crate.types.ParameterTypeSignature)1 TypeSignature (io.crate.types.TypeSignature)1