Search in sources :

Example 6 with TypeRef

use of com.google.api.tools.framework.model.TypeRef in project toolkit by googleapis.

the class PhpApiMethodParamTransformer method generateMethodParams.

@Override
public List<DynamicLangDefaultableParamView> generateMethodParams(GapicMethodContext context) {
    ImmutableList.Builder<DynamicLangDefaultableParamView> methodParams = ImmutableList.builder();
    methodParams.addAll(generateDefaultableParams(context));
    TypeRef arrayType = TypeRef.fromPrimitiveName("string").makeRepeated();
    DynamicLangDefaultableParamView.Builder optionalArgs = DynamicLangDefaultableParamView.newBuilder();
    optionalArgs.name(context.getNamer().localVarName(Name.from("optional", "args")));
    optionalArgs.defaultValue(context.getTypeTable().getSnippetZeroValueAndSaveNicknameFor(arrayType));
    methodParams.add(optionalArgs.build());
    return methodParams.build();
}
Also used : DynamicLangDefaultableParamView(com.google.api.codegen.viewmodel.DynamicLangDefaultableParamView) ImmutableList(com.google.common.collect.ImmutableList) TypeRef(com.google.api.tools.framework.model.TypeRef)

Example 7 with TypeRef

use of com.google.api.tools.framework.model.TypeRef in project toolkit by googleapis.

the class CSharpModelTypeNameConverterTest method testGetEnumValue.

@Test
public void testGetEnumValue() {
    String packageName = "Google.Example.Library.V1";
    TypeRef type = ModelTypeNameConverterTestUtil.getTestEnumType(tempDir);
    EnumValue value = type.getEnumType().getValues().get(0);
    CSharpModelTypeNameConverter converter = new CSharpModelTypeNameConverter(packageName);
    Truth.assertThat(converter.getEnumValue(type, value).getValueAndSaveTypeNicknameIn(new CSharpTypeTable(packageName))).isEqualTo("Book.Types.Rating.Good");
}
Also used : TypeRef(com.google.api.tools.framework.model.TypeRef) EnumValue(com.google.api.tools.framework.model.EnumValue) CSharpTypeTable(com.google.api.codegen.util.csharp.CSharpTypeTable) Test(org.junit.Test)

Example 8 with TypeRef

use of com.google.api.tools.framework.model.TypeRef in project toolkit by googleapis.

the class GoModelTypeNameConverterTest method testGetEnumValue.

@Test
public void testGetEnumValue() {
    TypeRef type = ModelTypeNameConverterTestUtil.getTestEnumType(tempDir);
    EnumValue value = type.getEnumType().getValues().get(0);
    Truth.assertThat(converter.getEnumValue(type, value).getValueAndSaveTypeNicknameIn(new GoTypeTable())).isEqualTo("librarypb.Book_GOOD");
    type = ModelTypeNameConverterTestUtil.getTestType(tempDir, "TopLevelEnum");
    value = type.getEnumType().getValues().get(0);
    Truth.assertThat(converter.getEnumValue(type, value).getValueAndSaveTypeNicknameIn(new GoTypeTable())).isEqualTo("librarypb.TopLevelEnum_FOO");
}
Also used : GoTypeTable(com.google.api.codegen.util.go.GoTypeTable) TypeRef(com.google.api.tools.framework.model.TypeRef) EnumValue(com.google.api.tools.framework.model.EnumValue) Test(org.junit.Test)

Example 9 with TypeRef

use of com.google.api.tools.framework.model.TypeRef in project toolkit by googleapis.

the class RubyModelTypeNameConverterTest method testGetEnumValue.

@Test
public void testGetEnumValue() {
    String packageName = "Library::V1";
    TypeRef type = ModelTypeNameConverterTestUtil.getTestEnumType(tempDir);
    EnumValue value = type.getEnumType().getValues().get(0);
    RubyModelTypeNameConverter converter = new RubyModelTypeNameConverter(packageName);
    Truth.assertThat(converter.getEnumValue(type, value).getValueAndSaveTypeNicknameIn(new RubyTypeTable(packageName))).isEqualTo(":GOOD");
}
Also used : RubyTypeTable(com.google.api.codegen.util.ruby.RubyTypeTable) TypeRef(com.google.api.tools.framework.model.TypeRef) EnumValue(com.google.api.tools.framework.model.EnumValue) Test(org.junit.Test)

Aggregations

TypeRef (com.google.api.tools.framework.model.TypeRef)9 EnumValue (com.google.api.tools.framework.model.EnumValue)5 Test (org.junit.Test)5 ImmutableList (com.google.common.collect.ImmutableList)2 IamResourceProto (com.google.api.codegen.IamResourceProto)1 FieldModel (com.google.api.codegen.config.FieldModel)1 GapicMethodConfig (com.google.api.codegen.config.GapicMethodConfig)1 MethodConfig (com.google.api.codegen.config.MethodConfig)1 CSharpTypeTable (com.google.api.codegen.util.csharp.CSharpTypeTable)1 GoTypeTable (com.google.api.codegen.util.go.GoTypeTable)1 JSTypeTable (com.google.api.codegen.util.js.JSTypeTable)1 PhpTypeTable (com.google.api.codegen.util.php.PhpTypeTable)1 RubyTypeTable (com.google.api.codegen.util.ruby.RubyTypeTable)1 DynamicLangDefaultableParamView (com.google.api.codegen.viewmodel.DynamicLangDefaultableParamView)1 Field (com.google.api.tools.framework.model.Field)1 Nullable (javax.annotation.Nullable)1 Duration (org.threeten.bp.Duration)1