use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.
the class JavaSampleImportTransformer method addSampleBodyImports.
@Override
protected void addSampleBodyImports(MethodContext context, CallingForm form) {
ImportTypeTable typeTable = context.getTypeTable();
MethodModel method = context.getMethodModel();
SurfaceNamer namer = context.getNamer();
switch(form) {
case Request:
case Flattened:
saveResponseTypeName(context);
break;
case RequestPaged:
saveResourceTypeName(context);
break;
case FlattenedPaged:
case CallablePaged:
typeTable.saveNicknameFor(API_FUTURE);
saveResponseTypeName(context);
saveResourceTypeName(context);
break;
case Callable:
typeTable.saveNicknameFor(API_FUTURE);
typeTable.getAndSaveNicknameFor(namer.getGenericAwareResponseTypeName(context));
break;
case CallableList:
saveResponseTypeName(context);
saveResourceTypeName(context);
break;
case CallableStreamingBidi:
typeTable.saveNicknameFor(BIDI_STEAMING_CALLABLE);
typeTable.getAndSaveNicknameFor(namer.getGenericAwareResponseTypeName(context));
break;
case CallableStreamingClient:
typeTable.saveNicknameFor(API_STREAM_OBSERVER);
typeTable.getAndSaveNicknameFor(namer.getGenericAwareResponseTypeName(context));
break;
case CallableStreamingServer:
typeTable.saveNicknameFor(SERVER_STREAM);
typeTable.getAndSaveNicknameFor(namer.getGenericAwareResponseTypeName(context));
break;
case LongRunningFlattenedAsync:
case LongRunningRequestAsync:
case LongRunningCallable:
typeTable.saveNicknameFor(OPERATION_FUTURE);
saveMetadataTypeNameForLongRunningMethod(context);
saveResponseTypeNameForLongRunningMethod(context);
break;
}
}
use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.
the class JavaSurfaceTestTransformer method addUnitTestImports.
// ///////////////////////////////// Imports //////////////////////////////////////
private void addUnitTestImports(InterfaceContext context) {
ImportTypeTable typeTable = context.getImportTypeTable();
typeTable.saveNicknameFor("com.google.api.gax.core.NoCredentialsProvider");
typeTable.saveNicknameFor("com.google.api.gax.rpc.InvalidArgumentException");
typeTable.saveNicknameFor("com.google.common.collect.Lists");
typeTable.saveNicknameFor("java.io.IOException");
typeTable.saveNicknameFor("java.util.Arrays");
typeTable.saveNicknameFor("java.util.List");
typeTable.saveNicknameFor("org.junit.After");
typeTable.saveNicknameFor("org.junit.AfterClass");
typeTable.saveNicknameFor("org.junit.Assert");
typeTable.saveNicknameFor("org.junit.BeforeClass");
typeTable.saveNicknameFor("org.junit.Test");
if (context.getInterfaceConfig().hasLongRunningOperations()) {
typeTable.saveNicknameFor("com.google.protobuf.Any");
}
switch(context.getProductConfig().getTransportProtocol()) {
case GRPC:
typeTable.saveNicknameFor("com.google.api.gax.rpc.ApiClientHeaderProvider");
typeTable.saveNicknameFor("com.google.api.gax.rpc.StatusCode");
typeTable.saveNicknameFor("com.google.api.gax.grpc.GaxGrpcProperties");
typeTable.saveNicknameFor("com.google.api.gax.grpc.GrpcStatusCode");
typeTable.saveNicknameFor("com.google.api.gax.grpc.testing.LocalChannelProvider");
typeTable.saveNicknameFor("com.google.api.gax.grpc.testing.MockGrpcService");
typeTable.saveNicknameFor("com.google.api.gax.grpc.testing.MockServiceHelper");
typeTable.saveNicknameFor("com.google.protobuf.AbstractMessage");
typeTable.saveNicknameFor("io.grpc.Status");
typeTable.saveNicknameFor("io.grpc.StatusRuntimeException");
typeTable.saveNicknameFor("java.util.ArrayList");
typeTable.saveNicknameFor("java.util.Objects");
typeTable.saveNicknameFor("java.util.concurrent.ExecutionException");
typeTable.saveNicknameFor("java.util.UUID");
typeTable.saveNicknameFor("org.junit.Before");
break;
case HTTP:
typeTable.saveNicknameFor("com.google.api.gax.httpjson.ApiMethodDescriptor");
typeTable.saveNicknameFor("com.google.api.gax.httpjson.GaxHttpJsonProperties");
typeTable.saveNicknameFor("com.google.api.gax.httpjson.testing.MockHttpService");
typeTable.saveNicknameFor("com.google.api.gax.rpc.ApiClientHeaderProvider");
typeTable.saveNicknameFor("com.google.api.gax.rpc.ApiException");
typeTable.saveNicknameFor("com.google.api.gax.rpc.ApiExceptionFactory");
typeTable.saveNicknameFor("com.google.api.gax.rpc.StatusCode.Code");
typeTable.saveNicknameFor("com.google.api.gax.rpc.testing.FakeStatusCode");
typeTable.saveNicknameFor("com.google.common.collect.ImmutableList");
typeTable.saveNicknameFor("java.util.Map");
typeTable.saveNicknameFor("java.util.HashMap");
// Import stub settings class in unit test file.
SurfaceNamer stubNamer = context.getNamer().cloneWithPackageName(context.getNamer().getStubPackageName());
TypeName rpcStubClassName = stubNamer.getTypeNameConverter().getTypeNameInImplicitPackage(stubNamer.getApiStubSettingsClassName(context.getInterfaceConfig()));
rpcStubClassName.getAndSaveNicknameIn(typeTable.getTypeTable());
break;
}
}
use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.
the class JavaSurfaceTestTransformer method addSmokeTestImports.
/**
* package-private
*/
void addSmokeTestImports(InterfaceContext context) {
ImportTypeTable typeTable = context.getImportTypeTable();
typeTable.saveNicknameFor("java.util.logging.Level");
typeTable.saveNicknameFor("java.util.logging.Logger");
typeTable.saveNicknameFor("java.util.List");
typeTable.saveNicknameFor("java.util.Arrays");
typeTable.saveNicknameFor("com.google.common.base.Preconditions");
typeTable.saveNicknameFor("com.google.common.collect.Lists");
typeTable.saveNicknameFor("org.junit.Test");
}
use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.
the class CSharpSampleImportTransformer method addInitCodeImports.
@Override
protected void addInitCodeImports(MethodContext context, ImportTypeTable initCodeTypeTable, Iterable<InitCodeNode> nodes) {
ImportTypeTable typeTable = context.getTypeTable();
typeTable.saveNicknameFor(context.getNamer().getFullyQualifiedApiWrapperClassName(context.getInterfaceConfig()));
Streams.stream(nodes).map(InitCodeNode::getType).forEach(typeTable::getAndSaveNicknameFor);
if (Streams.stream(nodes).anyMatch(n -> n.getLineType() == InitCodeLineType.ReadFileInitLine)) {
typeTable.saveNicknameFor("System.IO.File");
}
if (Streams.stream(nodes).anyMatch(n -> n.getLineType() == InitCodeLineType.ListInitLine)) {
typeTable.saveNicknameFor("System.Collections.Generic.IEnumerable");
}
if (Streams.stream(nodes).anyMatch(n -> n.getLineType() == InitCodeLineType.MapInitLine)) {
typeTable.saveNicknameFor("System.Collections.Generic.IDictionary");
}
}
use of com.google.api.codegen.transformer.ImportTypeTable in project toolkit by googleapis.
the class JavaSurfaceTestTransformer method addMockServiceImplImports.
private void addMockServiceImplImports(InterfaceContext context) {
ImportTypeTable typeTable = context.getImportTypeTable();
typeTable.saveNicknameFor("java.util.ArrayList");
typeTable.saveNicknameFor("java.util.List");
typeTable.saveNicknameFor("java.util.LinkedList");
typeTable.saveNicknameFor("java.util.Queue");
typeTable.saveNicknameFor("com.google.api.core.BetaApi");
typeTable.saveNicknameFor("com.google.common.collect.Lists");
if (context.getProductConfig().getTransportProtocol().equals(TransportProtocol.GRPC)) {
typeTable.saveNicknameFor("com.google.protobuf.AbstractMessage");
typeTable.saveNicknameFor("io.grpc.stub.StreamObserver");
}
}
Aggregations