From d686c96bb1929f881868473616cabe369adcc5c2 Mon Sep 17 00:00:00 2001 From: Mira Leung Date: Mon, 15 Feb 2021 16:36:22 -0800 Subject: [PATCH] chore(engx): Add class object to TypeNode (#654) --- .../java/com/google/api/generator/engine/ast/TypeNode.java | 3 +++ .../api/generator/gapic/composer/RetrySettingsComposer.java | 5 +---- .../gapic/composer/ServiceClientTestClassComposer.java | 6 +----- .../gapic/composer/ServiceStubSettingsClassComposer.java | 6 +----- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/google/api/generator/engine/ast/TypeNode.java b/src/main/java/com/google/api/generator/engine/ast/TypeNode.java index aef8f15727..46403071e1 100644 --- a/src/main/java/com/google/api/generator/engine/ast/TypeNode.java +++ b/src/main/java/com/google/api/generator/engine/ast/TypeNode.java @@ -65,6 +65,9 @@ public enum TypeKind { public static final TypeNode SHORT_OBJECT = withReference(ConcreteReference.withClazz(Short.class)); + public static final TypeNode CLASS_OBJECT = + withReference(ConcreteReference.withClazz(Class.class)); + public static final TypeNode BYTESTRING = TypeNode.withReference(ConcreteReference.withClazz(ByteString.class)); diff --git a/src/main/java/com/google/api/generator/gapic/composer/RetrySettingsComposer.java b/src/main/java/com/google/api/generator/gapic/composer/RetrySettingsComposer.java index 0118d43eb1..77253189d2 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/RetrySettingsComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/RetrySettingsComposer.java @@ -316,10 +316,7 @@ public static Expr createLroSettingsBuilderExpr( t -> VariableExpr.builder() .setVariable( - Variable.builder() - .setType(TypeNode.withReference(ConcreteReference.withClazz(Class.class))) - .setName("class") - .build()) + Variable.builder().setType(TypeNode.CLASS_OBJECT).setName("class").build()) .setStaticReferenceType(t) .build(); builderSettingsExpr = diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientTestClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientTestClassComposer.java index 0b27868b1c..3b3bd8cddb 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceClientTestClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceClientTestClassComposer.java @@ -1561,11 +1561,7 @@ private static List createRpcLroExceptionTestCatchBody( Expr testExpectedValueExpr = VariableExpr.builder() - .setVariable( - Variable.builder() - .setType(TypeNode.withReference(ConcreteReference.withClazz(Class.class))) - .setName("class") - .build()) + .setVariable(Variable.builder().setType(TypeNode.CLASS_OBJECT).setName("class").build()) .setStaticReferenceType(FIXED_TYPESTORE.get("InvalidArgumentException")) .build(); Expr getCauseExpr = diff --git a/src/main/java/com/google/api/generator/gapic/composer/ServiceStubSettingsClassComposer.java b/src/main/java/com/google/api/generator/gapic/composer/ServiceStubSettingsClassComposer.java index 45317be985..2774b90c3e 100644 --- a/src/main/java/com/google/api/generator/gapic/composer/ServiceStubSettingsClassComposer.java +++ b/src/main/java/com/google/api/generator/gapic/composer/ServiceStubSettingsClassComposer.java @@ -999,11 +999,7 @@ private static List createDefaultHelperAndGetterMethods( .setArguments( VariableExpr.builder() .setVariable( - Variable.builder() - .setType( - TypeNode.withReference(ConcreteReference.withClazz(Class.class))) - .setName("class") - .build()) + Variable.builder().setType(TypeNode.CLASS_OBJECT).setName("class").build()) .setStaticReferenceType( typeStore.get(ClassNames.getServiceStubSettingsClassName(service))) .build())