use of com.google.api.generator.engine.ast.EnumRefExpr in project gapic-generator-java by googleapis.
the class JavaWriterVisitorTest method writeEnumRefExpr_basic.
@Test
public void writeEnumRefExpr_basic() {
TypeNode enumType = TypeNode.withReference(ConcreteReference.builder().setClazz(TypeNode.TypeKind.class).setIsStaticImport(true).build());
EnumRefExpr enumRefExpr = EnumRefExpr.builder().setName("VOID").setType(enumType).build();
enumRefExpr.accept(writerVisitor);
assertEquals("TypeKind.VOID", writerVisitor.write());
}
use of com.google.api.generator.engine.ast.EnumRefExpr in project gapic-generator-java by googleapis.
the class ImportWriterVisitorTest method writeEnumRefExprImports_basic.
@Test
public void writeEnumRefExprImports_basic() {
TypeNode enumType = TypeNode.withReference(ConcreteReference.builder().setClazz(TypeNode.TypeKind.class).setIsStaticImport(true).build());
EnumRefExpr enumRefExpr = EnumRefExpr.builder().setName("VOID").setType(enumType).build();
enumRefExpr.accept(writerVisitor);
assertEquals("import static com.google.api.generator.engine.ast.TypeNode.TypeKind;\n\n", writerVisitor.write());
}
use of com.google.api.generator.engine.ast.EnumRefExpr in project gapic-generator-java by googleapis.
the class JavaWriterVisitorTest method writeEnumRefExpr_nested.
@Test
public void writeEnumRefExpr_nested() {
TypeNode enumType = TypeNode.withReference(ConcreteReference.withClazz(TypeNode.TypeKind.class));
EnumRefExpr enumRefExpr = EnumRefExpr.builder().setName("VOID").setType(enumType).build();
enumRefExpr.accept(writerVisitor);
assertEquals("TypeNode.TypeKind.VOID", writerVisitor.write());
}
use of com.google.api.generator.engine.ast.EnumRefExpr 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);
}
use of com.google.api.generator.engine.ast.EnumRefExpr in project gapic-generator-java by googleapis.
the class ImportWriterVisitorTest method writeEnumRefExprImports_nested.
@Test
public void writeEnumRefExprImports_nested() {
TypeNode enumType = TypeNode.withReference(ConcreteReference.withClazz(TypeNode.TypeKind.class));
EnumRefExpr enumRefExpr = EnumRefExpr.builder().setName("VOID").setType(enumType).build();
enumRefExpr.accept(writerVisitor);
assertEquals("import com.google.api.generator.engine.ast.TypeNode;\n\n", writerVisitor.write());
}
Aggregations