Search in sources :

Example 1 with MethodType

use of com.google.api.gax.httpjson.ApiMethodDescriptor.MethodType in project gapic-generator-java by googleapis.

the class HttpJsonServiceStubClassComposer method getMethodTypeExpr.

private List<Expr> getMethodTypeExpr(Method protoMethod) {
    MethodType methodType;
    switch(protoMethod.stream()) {
        case NONE:
            methodType = MethodType.UNARY;
            break;
        case SERVER:
            methodType = MethodType.SERVER_STREAMING;
            break;
        case CLIENT:
        // Not feasible to suppor in REST
        case BIDI:
        // Not feasible to suppor in REST
        default:
            throw new UnsupportedOperationException(String.format("Methods of type %s are not supported by REST transport", protoMethod.stream()));
    }
    EnumRefExpr expr = EnumRefExpr.builder().setName(methodType.toString()).setType(TypeNode.withReference(ConcreteReference.builder().setClazz(ApiMethodDescriptor.MethodType.class).build())).build();
    return Collections.singletonList(expr);
}
Also used : MethodType(com.google.api.gax.httpjson.ApiMethodDescriptor.MethodType) ApiMethodDescriptor(com.google.api.gax.httpjson.ApiMethodDescriptor) EnumRefExpr(com.google.api.generator.engine.ast.EnumRefExpr)

Aggregations

ApiMethodDescriptor (com.google.api.gax.httpjson.ApiMethodDescriptor)1 MethodType (com.google.api.gax.httpjson.ApiMethodDescriptor.MethodType)1 EnumRefExpr (com.google.api.generator.engine.ast.EnumRefExpr)1