Skip to content

Commit 6e8d098

Browse files
authored
fix: cleanup @BetaApi from Resource Name Builder Methods (#2450)
fixes #2099
1 parent 8123f0b commit 6e8d098

File tree

14 files changed

+1
-218
lines changed

14 files changed

+1
-218
lines changed

gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/resourcename/ResourceNameHelperClassComposer.java

+1-36
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
package com.google.api.generator.gapic.composer.resourcename;
1616

17-
import com.google.api.core.BetaApi;
1817
import com.google.api.generator.engine.ast.AnnotationNode;
1918
import com.google.api.generator.engine.ast.AssignmentExpr;
2019
import com.google.api.generator.engine.ast.AssignmentOperationExpr;
@@ -60,7 +59,6 @@
6059
import com.google.common.collect.ImmutableMap;
6160
import java.util.ArrayList;
6261
import java.util.Arrays;
63-
import java.util.Collections;
6462
import java.util.HashMap;
6563
import java.util.Iterator;
6664
import java.util.LinkedHashSet;
@@ -503,13 +501,6 @@ private static List<MethodDefinition> createBuilderCreatorMethods(
503501
ResourceName resourceName, List<List<String>> tokenHierarchies, TypeStore typeStore) {
504502
List<MethodDefinition> javaMethods = new ArrayList<>();
505503
String newMethodNameFormat = "new%s";
506-
AnnotationNode betaAnnotation =
507-
AnnotationNode.builder()
508-
.setType(FIXED_TYPESTORE.get("BetaApi"))
509-
.setDescription(
510-
"The per-pattern Builders are not stable yet and may be changed in the future.")
511-
.build();
512-
List<AnnotationNode> annotations = Arrays.asList(betaAnnotation);
513504

514505
// Create the newBuilder and variation methods here.
515506
// Variation example: newProjectLocationAutoscalingPolicyBuilder().
@@ -533,17 +524,13 @@ private static List<MethodDefinition> createBuilderCreatorMethods(
533524

534525
String variantName = getBuilderTypeName(tokenHierarchies, i);
535526
javaMethods.add(
536-
methodDefStarterFn
537-
.apply(String.format(newMethodNameFormat, variantName))
538-
.setAnnotations(i == 0 ? Collections.emptyList() : annotations)
539-
.build());
527+
methodDefStarterFn.apply(String.format(newMethodNameFormat, variantName)).build());
540528
if (i == 0 && tokenHierarchies.size() > 1) {
541529
// Create another builder creator method, but with the per-variant name.
542530
javaMethods.add(
543531
methodDefStarterFn
544532
.apply(
545533
String.format(newMethodNameFormat, getBuilderTypeName(tokenHierarchies.get(i))))
546-
.setAnnotations(annotations)
547534
.build());
548535
}
549536
}
@@ -597,15 +584,6 @@ private static List<MethodDefinition> createOfOrFormatMethodHelper(
597584
String setMethodNameFormat = "set%s";
598585
String buildMethodName = "build";
599586
String toStringMethodName = "toString";
600-
AnnotationNode betaAnnotation =
601-
AnnotationNode.builder()
602-
.setType(FIXED_TYPESTORE.get("BetaApi"))
603-
.setDescription(
604-
String.format(
605-
"The static %s methods are not stable yet and may be changed in the future.",
606-
isFormatMethod ? "format" : "create"))
607-
.build();
608-
List<AnnotationNode> annotations = Arrays.asList(betaAnnotation);
609587

610588
TypeNode thisClassType = typeStore.get(getThisClassName(resourceName));
611589
TypeNode returnType = isFormatMethod ? TypeNode.STRING : thisClassType;
@@ -624,7 +602,6 @@ private static List<MethodDefinition> createOfOrFormatMethodHelper(
624602
MethodDefinition.builder()
625603
.setScope(ScopeNode.PUBLIC)
626604
.setIsStatic(true)
627-
.setAnnotations(annotations)
628605
.setReturnType(returnType)
629606
.setName(
630607
String.format(methodNameFormat, concatToUpperCamelCaseName(tokens) + "Name"))
@@ -682,7 +659,6 @@ private static List<MethodDefinition> createOfOrFormatMethodHelper(
682659
MethodDefinition.builder()
683660
.setScope(ScopeNode.PUBLIC)
684661
.setIsStatic(true)
685-
.setAnnotations(i == 0 ? Collections.emptyList() : annotations)
686662
.setReturnType(returnType)
687663
.setName(
688664
String.format(
@@ -696,7 +672,6 @@ private static List<MethodDefinition> createOfOrFormatMethodHelper(
696672
MethodDefinition.builder()
697673
.setScope(ScopeNode.PUBLIC)
698674
.setIsStatic(true)
699-
.setAnnotations(annotations)
700675
.setReturnType(returnType)
701676
.setName(
702677
String.format(
@@ -1701,21 +1676,12 @@ private static ClassDefinition createNestedBuilderClass(
17011676
nestedClassMethods.add(buildMethod);
17021677

17031678
// Return the class.
1704-
AnnotationNode betaAnnotation =
1705-
AnnotationNode.builder()
1706-
.setType(FIXED_TYPESTORE.get("BetaApi"))
1707-
.setDescription(
1708-
"The per-pattern Builders are not stable yet and may be changed in the future.")
1709-
.build();
1710-
List<AnnotationNode> classAnnotations =
1711-
isDefaultClass ? Collections.emptyList() : Arrays.asList(betaAnnotation);
17121679

17131680
return ClassDefinition.builder()
17141681
.setHeaderCommentStatements(
17151682
CommentStatement.withComment(
17161683
JavaDocComment.withComment(
17171684
String.format(BUILDER_CLASS_HEADER_PATTERN, resourceNamePattern))))
1718-
.setAnnotations(classAnnotations)
17191685
.setIsNested(true)
17201686
.setScope(ScopeNode.PUBLIC)
17211687
.setIsStatic(true)
@@ -1729,7 +1695,6 @@ private static TypeStore createStaticTypes() {
17291695
List<Class<?>> concreteClazzes =
17301696
Arrays.asList(
17311697
ArrayList.class,
1732-
BetaApi.class,
17331698
Generated.class,
17341699
ImmutableMap.class,
17351700
List.class,

gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/resourcename/goldens/AgentName.golden

-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.google.cloud.dialogflow.v2beta1;
22

3-
import com.google.api.core.BetaApi;
43
import com.google.api.pathtemplate.PathTemplate;
54
import com.google.api.pathtemplate.ValidationException;
65
import com.google.api.resourcenames.ResourceName;
@@ -55,12 +54,10 @@ public class AgentName implements ResourceName {
5554
return new Builder();
5655
}
5756

58-
@BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.")
5957
public static Builder newProjectLocationBuilder() {
6058
return new Builder();
6159
}
6260

63-
@BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.")
6461
public static ProjectBuilder newProjectBuilder() {
6562
return new ProjectBuilder();
6663
}
@@ -73,12 +70,10 @@ public class AgentName implements ResourceName {
7370
return newBuilder().setProject(project).setLocation(location).build();
7471
}
7572

76-
@BetaApi("The static create methods are not stable yet and may be changed in the future.")
7773
public static AgentName ofProjectLocationName(String project, String location) {
7874
return newBuilder().setProject(project).setLocation(location).build();
7975
}
8076

81-
@BetaApi("The static create methods are not stable yet and may be changed in the future.")
8277
public static AgentName ofProjectName(String project) {
8378
return newProjectBuilder().setProject(project).build();
8479
}
@@ -87,12 +82,10 @@ public class AgentName implements ResourceName {
8782
return newBuilder().setProject(project).setLocation(location).build().toString();
8883
}
8984

90-
@BetaApi("The static format methods are not stable yet and may be changed in the future.")
9185
public static String formatProjectLocationName(String project, String location) {
9286
return newBuilder().setProject(project).setLocation(location).build().toString();
9387
}
9488

95-
@BetaApi("The static format methods are not stable yet and may be changed in the future.")
9689
public static String formatProjectName(String project) {
9790
return newProjectBuilder().setProject(project).build().toString();
9891
}
@@ -227,7 +220,6 @@ public class AgentName implements ResourceName {
227220
}
228221

229222
/** Builder for projects/{project}/agent. */
230-
@BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.")
231223
public static class ProjectBuilder {
232224
private String project;
233225

gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/resourcename/goldens/FoobarName.golden

-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.google.showcase.v1beta1;
22

3-
import com.google.api.core.BetaApi;
43
import com.google.api.pathtemplate.PathTemplate;
54
import com.google.api.pathtemplate.ValidationException;
65
import com.google.api.resourcenames.ResourceName;
@@ -92,22 +91,18 @@ public class FoobarName implements ResourceName {
9291
return new Builder();
9392
}
9493

95-
@BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.")
9694
public static Builder newProjectFoobarBuilder() {
9795
return new Builder();
9896
}
9997

100-
@BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.")
10198
public static ProjectVariantFoobarBuilder newProjectVariantFoobarBuilder() {
10299
return new ProjectVariantFoobarBuilder();
103100
}
104101

105-
@BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.")
106102
public static FoobarBuilder newFoobarBuilder() {
107103
return new FoobarBuilder();
108104
}
109105

110-
@BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.")
111106
public static BarFooFoobarBuilder newBarFooFoobarBuilder() {
112107
return new BarFooFoobarBuilder();
113108
}
@@ -120,12 +115,10 @@ public class FoobarName implements ResourceName {
120115
return newBuilder().setProject(project).setFoobar(foobar).build();
121116
}
122117

123-
@BetaApi("The static create methods are not stable yet and may be changed in the future.")
124118
public static FoobarName ofProjectFoobarName(String project, String foobar) {
125119
return newBuilder().setProject(project).setFoobar(foobar).build();
126120
}
127121

128-
@BetaApi("The static create methods are not stable yet and may be changed in the future.")
129122
public static FoobarName ofProjectVariantFoobarName(
130123
String project, String variant, String foobar) {
131124
return newProjectVariantFoobarBuilder()
@@ -135,12 +128,10 @@ public class FoobarName implements ResourceName {
135128
.build();
136129
}
137130

138-
@BetaApi("The static create methods are not stable yet and may be changed in the future.")
139131
public static FoobarName ofFoobarName(String foobar) {
140132
return newFoobarBuilder().setFoobar(foobar).build();
141133
}
142134

143-
@BetaApi("The static create methods are not stable yet and may be changed in the future.")
144135
public static FoobarName ofBarFooFoobarName(String barFoo, String foobar) {
145136
return newBarFooFoobarBuilder().setBarFoo(barFoo).setFoobar(foobar).build();
146137
}
@@ -149,12 +140,10 @@ public class FoobarName implements ResourceName {
149140
return newBuilder().setProject(project).setFoobar(foobar).build().toString();
150141
}
151142

152-
@BetaApi("The static format methods are not stable yet and may be changed in the future.")
153143
public static String formatProjectFoobarName(String project, String foobar) {
154144
return newBuilder().setProject(project).setFoobar(foobar).build().toString();
155145
}
156146

157-
@BetaApi("The static format methods are not stable yet and may be changed in the future.")
158147
public static String formatProjectVariantFoobarName(
159148
String project, String variant, String foobar) {
160149
return newProjectVariantFoobarBuilder()
@@ -165,12 +154,10 @@ public class FoobarName implements ResourceName {
165154
.toString();
166155
}
167156

168-
@BetaApi("The static format methods are not stable yet and may be changed in the future.")
169157
public static String formatFoobarName(String foobar) {
170158
return newFoobarBuilder().setFoobar(foobar).build().toString();
171159
}
172160

173-
@BetaApi("The static format methods are not stable yet and may be changed in the future.")
174161
public static String formatBarFooFoobarName(String barFoo, String foobar) {
175162
return newBarFooFoobarBuilder().setBarFoo(barFoo).setFoobar(foobar).build().toString();
176163
}
@@ -327,7 +314,6 @@ public class FoobarName implements ResourceName {
327314
}
328315

329316
/** Builder for projects/{project}/chocolate/variants/{variant}/foobars/{foobar}. */
330-
@BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.")
331317
public static class ProjectVariantFoobarBuilder {
332318
private String project;
333319
private String variant;
@@ -368,7 +354,6 @@ public class FoobarName implements ResourceName {
368354
}
369355

370356
/** Builder for foobars/{foobar}. */
371-
@BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.")
372357
public static class FoobarBuilder {
373358
private String foobar;
374359

@@ -389,7 +374,6 @@ public class FoobarName implements ResourceName {
389374
}
390375

391376
/** Builder for bar_foos/{bar_foo}/foobars/{foobar}. */
392-
@BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.")
393377
public static class BarFooFoobarBuilder {
394378
private String barFoo;
395379
private String foobar;

showcase/proto-gapic-showcase-v1beta1/src/main/java/com/google/showcase/v1beta1/BlurbName.java

-16
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.google.showcase.v1beta1;
1818

19-
import com.google.api.core.BetaApi;
2019
import com.google.api.pathtemplate.PathTemplate;
2120
import com.google.api.pathtemplate.ValidationException;
2221
import com.google.api.resourcenames.ResourceName;
@@ -118,22 +117,18 @@ public static Builder newBuilder() {
118117
return new Builder();
119118
}
120119

121-
@BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.")
122120
public static Builder newUserLegacyUserBlurbBuilder() {
123121
return new Builder();
124122
}
125123

126-
@BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.")
127124
public static UserBlurbBuilder newUserBlurbBuilder() {
128125
return new UserBlurbBuilder();
129126
}
130127

131-
@BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.")
132128
public static RoomBlurbBuilder newRoomBlurbBuilder() {
133129
return new RoomBlurbBuilder();
134130
}
135131

136-
@BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.")
137132
public static RoomLegacyRoomBlurbBuilder newRoomLegacyRoomBlurbBuilder() {
138133
return new RoomLegacyRoomBlurbBuilder();
139134
}
@@ -146,22 +141,18 @@ public static BlurbName of(String user, String legacyUser, String blurb) {
146141
return newBuilder().setUser(user).setLegacyUser(legacyUser).setBlurb(blurb).build();
147142
}
148143

149-
@BetaApi("The static create methods are not stable yet and may be changed in the future.")
150144
public static BlurbName ofUserLegacyUserBlurbName(String user, String legacyUser, String blurb) {
151145
return newBuilder().setUser(user).setLegacyUser(legacyUser).setBlurb(blurb).build();
152146
}
153147

154-
@BetaApi("The static create methods are not stable yet and may be changed in the future.")
155148
public static BlurbName ofUserBlurbName(String user, String blurb) {
156149
return newUserBlurbBuilder().setUser(user).setBlurb(blurb).build();
157150
}
158151

159-
@BetaApi("The static create methods are not stable yet and may be changed in the future.")
160152
public static BlurbName ofRoomBlurbName(String room, String blurb) {
161153
return newRoomBlurbBuilder().setRoom(room).setBlurb(blurb).build();
162154
}
163155

164-
@BetaApi("The static create methods are not stable yet and may be changed in the future.")
165156
public static BlurbName ofRoomLegacyRoomBlurbName(String room, String legacyRoom, String blurb) {
166157
return newRoomLegacyRoomBlurbBuilder()
167158
.setRoom(room)
@@ -174,22 +165,18 @@ public static String format(String user, String legacyUser, String blurb) {
174165
return newBuilder().setUser(user).setLegacyUser(legacyUser).setBlurb(blurb).build().toString();
175166
}
176167

177-
@BetaApi("The static format methods are not stable yet and may be changed in the future.")
178168
public static String formatUserLegacyUserBlurbName(String user, String legacyUser, String blurb) {
179169
return newBuilder().setUser(user).setLegacyUser(legacyUser).setBlurb(blurb).build().toString();
180170
}
181171

182-
@BetaApi("The static format methods are not stable yet and may be changed in the future.")
183172
public static String formatUserBlurbName(String user, String blurb) {
184173
return newUserBlurbBuilder().setUser(user).setBlurb(blurb).build().toString();
185174
}
186175

187-
@BetaApi("The static format methods are not stable yet and may be changed in the future.")
188176
public static String formatRoomBlurbName(String room, String blurb) {
189177
return newRoomBlurbBuilder().setRoom(room).setBlurb(blurb).build().toString();
190178
}
191179

192-
@BetaApi("The static format methods are not stable yet and may be changed in the future.")
193180
public static String formatRoomLegacyRoomBlurbName(String room, String legacyRoom, String blurb) {
194181
return newRoomLegacyRoomBlurbBuilder()
195182
.setRoom(room)
@@ -369,7 +356,6 @@ public BlurbName build() {
369356
}
370357

371358
/** Builder for users/{user}/profile/blurbs/{blurb}. */
372-
@BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.")
373359
public static class UserBlurbBuilder {
374360
private String user;
375361
private String blurb;
@@ -400,7 +386,6 @@ public BlurbName build() {
400386
}
401387

402388
/** Builder for rooms/{room}/blurbs/{blurb}. */
403-
@BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.")
404389
public static class RoomBlurbBuilder {
405390
private String room;
406391
private String blurb;
@@ -431,7 +416,6 @@ public BlurbName build() {
431416
}
432417

433418
/** Builder for rooms/{room}/blurbs/legacy/{legacy_room}.{blurb}. */
434-
@BetaApi("The per-pattern Builders are not stable yet and may be changed in the future.")
435419
public static class RoomLegacyRoomBlurbBuilder {
436420
private String room;
437421
private String legacyRoom;

0 commit comments

Comments
 (0)