|
29 | 29 | import com.google.api.generator.engine.ast.AnonymousClassExpr;
|
30 | 30 | import com.google.api.generator.engine.ast.AssignmentExpr;
|
31 | 31 | import com.google.api.generator.engine.ast.ClassDefinition;
|
| 32 | +import com.google.api.generator.engine.ast.CommentStatement; |
32 | 33 | import com.google.api.generator.engine.ast.ConcreteReference;
|
33 | 34 | import com.google.api.generator.engine.ast.EmptyLineStatement;
|
34 | 35 | import com.google.api.generator.engine.ast.EnumRefExpr;
|
35 | 36 | import com.google.api.generator.engine.ast.Expr;
|
36 | 37 | import com.google.api.generator.engine.ast.ExprStatement;
|
| 38 | +import com.google.api.generator.engine.ast.JavaDocComment; |
37 | 39 | import com.google.api.generator.engine.ast.MethodDefinition;
|
38 | 40 | import com.google.api.generator.engine.ast.MethodInvocationExpr;
|
39 | 41 | import com.google.api.generator.engine.ast.NewObjectExpr;
|
@@ -525,6 +527,8 @@ private static List<MethodDefinition> createConstructorMethods(
|
525 | 527 | MethodDefinition.constructorBuilder()
|
526 | 528 | .setScope(ScopeNode.PROTECTED)
|
527 | 529 | .setReturnType(thisClassType)
|
| 530 | + .setHeaderCommentStatements( |
| 531 | + Arrays.asList(createProtectedCtorComment(service.name()))) |
528 | 532 | .setArguments(
|
529 | 533 | args.stream()
|
530 | 534 | .map(v -> v.toBuilder().setIsDecl(true).build())
|
@@ -1143,4 +1147,14 @@ private static String getProtoRpcFullMethodName(Service protoService, Method pro
|
1143 | 1147 | private static String getThisClassName(String serviceName) {
|
1144 | 1148 | return String.format(CLASS_NAME_PATTERN, serviceName);
|
1145 | 1149 | }
|
| 1150 | + |
| 1151 | + private static CommentStatement createProtectedCtorComment(String serviceName) { |
| 1152 | + return CommentStatement.withComment( |
| 1153 | + JavaDocComment.withComment( |
| 1154 | + String.format( |
| 1155 | + "Constructs an instance of %s, using the given settings. This is protected so that" |
| 1156 | + + " it is easy to make a subclass, but otherwise, the static factory methods" |
| 1157 | + + " should be preferred.", |
| 1158 | + getThisClassName(serviceName)))); |
| 1159 | + } |
1146 | 1160 | }
|
0 commit comments