Skip to content

Commit 5fad1fe

Browse files
committed
Change isPublic attribute to isInternalApi in method class
1 parent 5a21be7 commit 5fad1fe

File tree

10 files changed

+28
-29
lines changed

10 files changed

+28
-29
lines changed

gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/comment/ServiceClientCommentComposer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public static List<CommentStatement> createRpcMethodHeaderComment(
202202
methodJavadocBuilder.setDeprecated(CommentComposer.DEPRECATED_METHOD_STRING);
203203
}
204204

205-
if (method.isPublic() == false) {
205+
if (method.isInternalApi()) {
206206
methodJavadocBuilder.setInternalOnly(CommentComposer.INTERNAL_ONLY_METHOD_STRING);
207207
}
208208

@@ -349,7 +349,7 @@ public static List<CommentStatement> createRpcCallableMethodHeaderComment(
349349
methodJavadocBuilder.setDeprecated(CommentComposer.DEPRECATED_METHOD_STRING);
350350
}
351351

352-
if (method.isPublic() == false) {
352+
if (method.isInternalApi()) {
353353
methodJavadocBuilder.setInternalOnly(CommentComposer.INTERNAL_ONLY_METHOD_STRING);
354354
}
355355

gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceClientClassComposer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ private static List<MethodDefinition> createMethodVariants(
809809
annotations.add(AnnotationNode.withType(TypeNode.DEPRECATED));
810810
}
811811

812-
if (method.isPublic() == false) {
812+
if (method.isInternalApi()) {
813813
annotations.add(
814814
AnnotationNode.withTypeAndDescription(
815815
typeStore.get("InternalApi"), INTERNAL_API_WARNING));
@@ -898,7 +898,7 @@ private static MethodDefinition createMethodDefaultMethod(
898898
annotations.add(AnnotationNode.withType(TypeNode.DEPRECATED));
899899
}
900900

901-
if (method.isPublic() == false) {
901+
if (method.isInternalApi()) {
902902
annotations.add(
903903
AnnotationNode.withTypeAndDescription(
904904
typeStore.get("InternalApi"), INTERNAL_API_WARNING));
@@ -1058,7 +1058,7 @@ private static MethodDefinition createCallableMethod(
10581058
if (method.isDeprecated()) {
10591059
annotations.add(AnnotationNode.withType(TypeNode.DEPRECATED));
10601060
}
1061-
if (method.isPublic() == false) {
1061+
if (method.isInternalApi()) {
10621062
annotations.add(
10631063
AnnotationNode.withTypeAndDescription(
10641064
typeStore.get("InternalApi"), INTERNAL_API_WARNING));

gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceSettingsClassComposer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ private static List<CommentStatement> createClassHeaderComments(
140140
// public in the
141141
// list.
142142
List<Method> publicMethods =
143-
service.methods().stream().filter(m -> m.isPublic() == true).collect(Collectors.toList());
143+
service.methods().stream().filter(m -> m.isInternalApi() == false).collect(Collectors.toList());
144144
Optional<Method> methodOpt =
145145
publicMethods.isEmpty()
146146
? Optional.empty()
@@ -298,7 +298,7 @@ private static MethodDefinition methodBuilderHelper(
298298
annotations.add(AnnotationNode.withType(TypeNode.DEPRECATED));
299299
}
300300

301-
if (protoMethod.isPublic() == false) {
301+
if (protoMethod.isInternalApi()) {
302302
annotations.add(
303303
AnnotationNode.withTypeAndDescription(
304304
FIXED_TYPESTORE.get("InternalApi"), INTERNAL_API_WARNING));
@@ -309,7 +309,7 @@ private static MethodDefinition methodBuilderHelper(
309309
SettingsCommentComposer.createCallSettingsGetterComment(
310310
getMethodNameFromSettingsVarName(javaMethodName),
311311
protoMethod.isDeprecated(),
312-
protoMethod.isPublic() == false))
312+
protoMethod.isInternalApi()))
313313
.setAnnotations(annotations)
314314
.build();
315315
}
@@ -783,7 +783,7 @@ private static List<MethodDefinition> createNestedBuilderSettingsGetterMethods(
783783
SettingsCommentComposer.createCallSettingsBuilderGetterComment(
784784
getMethodNameFromSettingsVarName(javaMethodName),
785785
protoMethod.isDeprecated(),
786-
protoMethod.isPublic() == false))
786+
protoMethod.isInternalApi()))
787787
.setAnnotations(
788788
protoMethod.isDeprecated()
789789
? Arrays.asList(AnnotationNode.withType(TypeNode.DEPRECATED))
@@ -800,7 +800,7 @@ private static List<MethodDefinition> createNestedBuilderSettingsGetterMethods(
800800
SettingsCommentComposer.createCallSettingsBuilderGetterComment(
801801
getMethodNameFromSettingsVarName(javaMethodName),
802802
protoMethod.isDeprecated(),
803-
protoMethod.isPublic() == false))
803+
protoMethod.isInternalApi()))
804804
.setAnnotations(
805805
protoMethod.isDeprecated()
806806
? Arrays.asList(AnnotationNode.withType(TypeNode.DEPRECATED))

gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubClassComposer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private MethodDefinition createCallableGetterHelper(
202202
if (method.isDeprecated()) {
203203
annotations.add(AnnotationNode.withType(TypeNode.DEPRECATED));
204204
}
205-
if (method.isPublic() == false) {
205+
if (method.isInternalApi()) {
206206
annotations.add(
207207
AnnotationNode.withTypeAndDescription(
208208
typeStore.get("InternalApi"), INTERNAL_API_WARNING));

gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/common/AbstractServiceStubSettingsClassComposer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ private static List<CommentStatement> createClassHeaderComments(
423423
// public in the
424424
// list.
425425
List<Method> publicMethods =
426-
service.methods().stream().filter(m -> m.isPublic() == true).collect(Collectors.toList());
426+
service.methods().stream().filter(m -> m.isInternalApi() == false).collect(Collectors.toList());
427427
Optional<Method> methodOpt =
428428
publicMethods.isEmpty()
429429
? Optional.empty()
@@ -502,7 +502,7 @@ private static Map<String, VariableExpr> createMethodSettingsClassMemberVarExprs
502502
if (method.isDeprecated()) {
503503
deprecatedSettingVarNames.add(varName);
504504
}
505-
if (method.isPublic() == false) {
505+
if (method.isInternalApi()) {
506506
internalSettingVarNames.add(varName);
507507
}
508508
varExprs.put(

gapic-generator-java/src/main/java/com/google/api/generator/gapic/composer/samplecode/ServiceClientHeaderSampleComposer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static Sample composeClassHeaderSample(
5353
Map<String, ResourceName> resourceNames,
5454
Map<String, Message> messageTypes) {
5555
List<Method> publicMethods =
56-
service.methods().stream().filter(m -> m.isPublic() == true).collect(Collectors.toList());
56+
service.methods().stream().filter(m -> m.isInternalApi() == false).collect(Collectors.toList());
5757

5858
// If all generated methods are INTERNAL, generate an empty service sample.
5959
if (publicMethods.isEmpty()) {

gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/Method.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public enum Stream {
3838

3939
public abstract TypeNode outputType();
4040

41-
public abstract boolean isPublic();
41+
public abstract boolean isInternalApi();
4242

4343
public abstract boolean isBatching();
4444

@@ -138,7 +138,7 @@ public static Builder builder() {
138138
.setStream(Stream.NONE)
139139
.setAutoPopulatedFields(new ArrayList<>())
140140
.setMethodSignatures(ImmutableList.of())
141-
.setIsPublic(true)
141+
.setIsInternalApi(false)
142142
.setIsBatching(false)
143143
.setIsDeprecated(false)
144144
.setOperationPollingMethod(false);
@@ -164,8 +164,7 @@ public abstract static class Builder {
164164
public abstract Builder setInputType(TypeNode inputType);
165165

166166
public abstract Builder setOutputType(TypeNode outputType);
167-
168-
public abstract Builder setIsPublic(boolean isPublic);
167+
public abstract Builder setIsInternalApi(boolean isInternalApi);
169168

170169
public abstract Builder setStream(Stream stream);
171170

gapic-generator-java/src/main/java/com/google/api/generator/gapic/protoparser/Parser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ static List<Method> parseMethods(
850850
.setName(protoMethod.getName())
851851
.setInputType(inputType)
852852
.setOutputType(TypeParser.parseType(protoMethod.getOutputType()))
853-
.setIsPublic(methodSelectiveGapicType == SelectiveGapicType.PUBLIC)
853+
.setIsInternalApi(methodSelectiveGapicType == SelectiveGapicType.INTERNAL)
854854
.setStream(
855855
Method.toStream(protoMethod.isClientStreaming(), protoMethod.isServerStreaming()))
856856
.setLro(parseLro(servicePackage, protoMethod, messageTypes))

gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/samplecode/ServiceClientHeaderSampleComposerTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,14 @@ void composeClassHeaderSample_firstMethodIsInternal() {
317317
.setName("ChatShouldGenerateAsInternal")
318318
.setInputType(inputType)
319319
.setOutputType(outputType)
320-
.setIsPublic(false)
320+
.setIsInternalApi(true)
321321
.build();
322322
Method publicMethod =
323323
Method.builder()
324324
.setName("ChatShouldGenerateAsPublic")
325325
.setInputType(inputType)
326326
.setOutputType(outputType)
327-
.setIsPublic(true)
327+
.setIsInternalApi(false)
328328
.build();
329329
Service service =
330330
Service.builder()
@@ -387,14 +387,14 @@ void composeClassHeaderSample_allMethodsAreInternal() {
387387
.setName("ChatShouldGenerateAsInternal")
388388
.setInputType(inputType)
389389
.setOutputType(outputType)
390-
.setIsPublic(false)
390+
.setIsInternalApi(true)
391391
.build();
392392
Method internalMethod2 =
393393
Method.builder()
394394
.setName("EchoShouldGenerateAsInternal")
395395
.setInputType(inputType)
396396
.setOutputType(outputType)
397-
.setIsPublic(false)
397+
.setIsInternalApi(true)
398398
.build();
399399
Service service =
400400
Service.builder()
@@ -421,7 +421,7 @@ void composeClassHeaderSample_allMethodsAreInternal() {
421421
LineFormatter.lines(
422422
"try (EchoServiceSelectiveApiClient echoServiceSelectiveApiClient =\n"
423423
+ " EchoServiceSelectiveApiClient.create()) {}");
424-
Assert.assertEquals(results, expected);
424+
Assert.assertEquals(expected, results);
425425
}
426426

427427
/*Testing composeSetCredentialsSample*/

gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ParserTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ void selectiveGenerationTest_shouldGenerateOnlySelectiveMethodsWithGenerateOmitt
761761
assertEquals(3, services.get(0).methods().size());
762762
for (Method method : services.get(0).methods()) {
763763
assertTrue(method.name().contains("ShouldGenerate"));
764-
assertTrue(method.isPublic());
764+
assertFalse(method.isInternalApi());
765765
}
766766
}
767767

@@ -789,24 +789,24 @@ void selectiveGenerationTest_shouldGenerateOmittedAsInternalWithGenerateOmittedT
789789
assertEquals("EchoServiceShouldGenerateAllPublic", services.get(0).overriddenName());
790790
assertEquals(3, services.get(0).methods().size());
791791
for (Method method : services.get(0).methods()) {
792-
assertTrue(method.isPublic());
792+
assertFalse(method.isInternalApi());
793793
}
794794

795795
// Tests a service with partial public methods and partial internal methods.
796796
assertEquals("EchoServiceShouldGeneratePartialPublic", services.get(1).overriddenName());
797797
assertEquals(5, services.get(1).methods().size());
798798
for (Method method : services.get(1).methods()) {
799799
if (method.name().contains("ShouldGenerateAsPublic")) {
800-
assertTrue(method.isPublic());
800+
assertFalse(method.isInternalApi());
801801
} else {
802-
assertFalse(method.isPublic());
802+
assertTrue(method.isInternalApi());
803803
}
804804
}
805805
// Tests a service with internal methods only.
806806
assertEquals("EchoServiceShouldGenerateAllInternal", services.get(2).overriddenName());
807807
assertEquals(2, services.get(2).methods().size());
808808
for (Method method : services.get(2).methods()) {
809-
assertFalse(method.isPublic());
809+
assertTrue(method.isInternalApi());
810810
}
811811
}
812812

0 commit comments

Comments
 (0)