1 // Copyright 2020 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package com.google.api.generator.gapic.composer.comment; 16 17 import com.google.api.generator.engine.ast.BlockComment; 18 import com.google.api.generator.engine.ast.CommentStatement; 19 import com.google.api.generator.engine.ast.LineComment; 20 import com.google.api.generator.engine.ast.Statement; 21 import java.util.Arrays; 22 import java.util.List; 23 24 public class CommentComposer { 25 private static final String APACHE_LICENSE_STRING = 26 "Copyright 2022 Google LLC\n\n" 27 + "Licensed under the Apache License, Version 2.0 (the \"License\");\n" 28 + "you may not use this file except in compliance with the License.\n" 29 + "You may obtain a copy of the License at\n\n" 30 + " https://www.apache.org/licenses/LICENSE-2.0\n\n" 31 + "Unless required by applicable law or agreed to in writing, software\n" 32 + "distributed under the License is distributed on an \"AS IS\" BASIS,\n" 33 + "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" 34 + "See the License for the specific language governing permissions and\n" 35 + "limitations under the License."; 36 37 private static final String AUTO_GENERATED_CLASS_DISCLAIMER_STRING = 38 "AUTO-GENERATED DOCUMENTATION AND CLASS."; 39 40 private static final String AUTO_GENERATED_METHOD_DISCLAIMER_STRING = 41 "AUTO-GENERATED DOCUMENTATION AND METHOD."; 42 43 static final String DEPRECATED_CLASS_STRING = 44 "This class is deprecated and will be removed in the next major version update."; 45 46 static final String DEPRECATED_METHOD_STRING = 47 "This method is deprecated and will be removed in the next major version update."; 48 49 public static final CommentStatement APACHE_LICENSE_COMMENT = 50 CommentStatement.withComment(BlockComment.withComment(APACHE_LICENSE_STRING)); 51 52 public static final CommentStatement AUTO_GENERATED_CLASS_COMMENT = 53 CommentStatement.withComment(LineComment.withComment(AUTO_GENERATED_CLASS_DISCLAIMER_STRING)); 54 55 public static final CommentStatement AUTO_GENERATED_METHOD_COMMENT = 56 CommentStatement.withComment( 57 LineComment.withComment(AUTO_GENERATED_METHOD_DISCLAIMER_STRING)); 58 59 public static final List<Statement> AUTO_GENERATED_SAMPLE_COMMENT = 60 Arrays.asList( 61 CommentStatement.withComment( 62 LineComment.withComment( 63 "This snippet has been automatically generated and should be regarded as a code template only.")), 64 CommentStatement.withComment( 65 LineComment.withComment("It will require modifications to work:")), 66 CommentStatement.withComment( 67 LineComment.withComment( 68 "- It may require correct/in-range values for request initialization.")), 69 CommentStatement.withComment( 70 LineComment.withComment( 71 "- It may require specifying regional endpoints when creating the service client as shown in")), 72 CommentStatement.withComment( 73 LineComment.withComment( 74 "https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library"))); 75 } 76