| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1a0e970 commit 8e884fd
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -66,10 +66,6 @@ | |||
| 66 | 66 | */ | |
| 67 | 67 | @javax.annotation.Generated("by GAPIC") | |
| 68 | 68 | public class PublisherApi implements AutoCloseable { | |
| 69 | - // ======== | ||
| 70 | - // Members | ||
| 71 | - // ======== | ||
| 72 | - | ||
| 73 | 69 | private final ManagedChannel channel; | |
| 74 | 70 | private final List<AutoCloseable> closeables = new ArrayList<>(); | |
| 75 | 71 | ||
@@ -84,105 +80,88 @@ public class PublisherApi implements AutoCloseable { | |||
| 84 | 80 | listTopicSubscriptionsIterableCallable; | |
| 85 | 81 | private final ApiCallable<DeleteTopicRequest, Empty> deleteTopicCallable; | |
| 86 | 82 | ||
| 87 | - public static class ResourceNames { | ||
| 88 | - | ||
| 89 | - // ======================= | ||
| 90 | - // ResourceNames Constants | ||
| 91 | - // ======================= | ||
| 92 | - | ||
| 93 | - /** | ||
| 94 | - * A PathTemplate representing the fully-qualified path to represent | ||
| 95 | - * a project resource. | ||
| 96 | - * | ||
| 97 | - * <!-- manual edit --> | ||
| 98 | - * <!-- end manual edit --> | ||
| 99 | - */ | ||
| 100 | - private static final PathTemplate PROJECT_PATH_TEMPLATE = | ||
| 101 | - PathTemplate.create("projects/{project}"); | ||
| 102 | - | ||
| 103 | - /** | ||
| 104 | - * A PathTemplate representing the fully-qualified path to represent | ||
| 105 | - * a topic resource. | ||
| 106 | - * | ||
| 107 | - * <!-- manual edit --> | ||
| 108 | - * <!-- end manual edit --> | ||
| 109 | - */ | ||
| 110 | - private static final PathTemplate TOPIC_PATH_TEMPLATE = | ||
| 111 | - PathTemplate.create("projects/{project}/topics/{topic}"); | ||
| 112 | - | ||
| 113 | - private ResourceNames() {} | ||
| 114 | - | ||
| 115 | - // ============================== | ||
| 116 | - // Resource Name Helper Functions | ||
| 117 | - // ============================== | ||
| 118 | - | ||
| 119 | - /** | ||
| 120 | - * Formats a string containing the fully-qualified path to represent | ||
| 121 | - * a project resource. | ||
| 122 | - * | ||
| 123 | - * <!-- manual edit --> | ||
| 124 | - * <!-- end manual edit --> | ||
| 125 | - */ | ||
| 126 | - public static final String formatProjectPath(String project) { | ||
| 127 | - return PROJECT_PATH_TEMPLATE.instantiate("project", project); | ||
| 128 | - } | ||
| 83 | + /** | ||
| 84 | + * A PathTemplate representing the fully-qualified path to represent | ||
| 85 | + * a project resource. | ||
| 86 | + * | ||
| 87 | + * <!-- manual edit --> | ||
| 88 | + * <!-- end manual edit --> | ||
| 89 | + */ | ||
| 90 | + private static final PathTemplate PROJECT_PATH_TEMPLATE = | ||
| 91 | + PathTemplate.create("projects/{project}"); | ||
| 129 | 92 | ||
| 130 | - /** | ||
| 131 | - * Formats a string containing the fully-qualified path to represent | ||
| 132 | - * a topic resource. | ||
| 133 | - * | ||
| 134 | - * <!-- manual edit --> | ||
| 135 | - * <!-- end manual edit --> | ||
| 136 | - */ | ||
| 137 | - public static final String formatTopicPath(String project, String topic) { | ||
| 138 | - return TOPIC_PATH_TEMPLATE.instantiate("project", project, "topic", topic); | ||
| 139 | - } | ||
| 93 | + /** | ||
| 94 | + * A PathTemplate representing the fully-qualified path to represent | ||
| 95 | + * a topic resource. | ||
| 96 | + * | ||
| 97 | + * <!-- manual edit --> | ||
| 98 | + * <!-- end manual edit --> | ||
| 99 | + */ | ||
| 100 | + private static final PathTemplate TOPIC_PATH_TEMPLATE = | ||
| 101 | + PathTemplate.create("projects/{project}/topics/{topic}"); | ||
| 140 | 102 | ||
| 141 | - /** | ||
| 142 | - * Parses the project from the given fully-qualified path which | ||
| 143 | - * represents a project resource. | ||
| 144 | - * | ||
| 145 | - * <!-- manual edit --> | ||
| 146 | - * <!-- end manual edit --> | ||
| 147 | - */ | ||
| 148 | - public static final String parseProjectFromProjectPath(String projectPath) { | ||
| 149 | - return PROJECT_PATH_TEMPLATE.parse(projectPath).get("project"); | ||
| 150 | - } | ||
| 103 | + /** | ||
| 104 | + * Formats a string containing the fully-qualified path to represent | ||
| 105 | + * a project resource. | ||
| 106 | + * | ||
| 107 | + * <!-- manual edit --> | ||
| 108 | + * <!-- end manual edit --> | ||
| 109 | + */ | ||
| 110 | + public static final String formatProjectName(String project) { | ||
| 111 | + return PROJECT_PATH_TEMPLATE.instantiate("project", project); | ||
| 112 | + } | ||
| 151 | 113 | ||
| 152 | - /** | ||
| 153 | - * Parses the project from the given fully-qualified path which | ||
| 154 | - * represents a topic resource. | ||
| 155 | - * | ||
| 156 | - * <!-- manual edit --> | ||
| 157 | - * <!-- end manual edit --> | ||
| 158 | - */ | ||
| 159 | - public static final String parseProjectFromTopicPath(String topicPath) { | ||
| 160 | - return TOPIC_PATH_TEMPLATE.parse(topicPath).get("project"); | ||
| 161 | - } | ||
| 114 | + /** | ||
| 115 | + * Formats a string containing the fully-qualified path to represent | ||
| 116 | + * a topic resource. | ||
| 117 | + * | ||
| 118 | + * <!-- manual edit --> | ||
| 119 | + * <!-- end manual edit --> | ||
| 120 | + */ | ||
| 121 | + public static final String formatTopicName(String project, String topic) { | ||
| 122 | + return TOPIC_PATH_TEMPLATE.instantiate("project", project, "topic", topic); | ||
| 123 | + } | ||
| 162 | 124 | ||
| 163 | - /** | ||
| 164 | - * Parses the topic from the given fully-qualified path which | ||
| 165 | - * represents a topic resource. | ||
| 166 | - * | ||
| 167 | - * <!-- manual edit --> | ||
| 168 | - * <!-- end manual edit --> | ||
| 169 | - */ | ||
| 170 | - public static final String parseTopicFromTopicPath(String topicPath) { | ||
| 171 | - return TOPIC_PATH_TEMPLATE.parse(topicPath).get("topic"); | ||
| 172 | - } | ||
| 125 | + /** | ||
| 126 | + * Parses the project from the given fully-qualified path which | ||
| 127 | + * represents a project resource. | ||
| 128 | + * | ||
| 129 | + * <!-- manual edit --> | ||
| 130 | + * <!-- end manual edit --> | ||
| 131 | + */ | ||
| 132 | + public static final String parseProjectFromProjectName(String projectName) { | ||
| 133 | + return PROJECT_PATH_TEMPLATE.parse(projectName).get("project"); | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + /** | ||
| 137 | + * Parses the project from the given fully-qualified path which | ||
| 138 | + * represents a topic resource. | ||
| 139 | + * | ||
| 140 | + * <!-- manual edit --> | ||
| 141 | + * <!-- end manual edit --> | ||
| 142 | + */ | ||
| 143 | + public static final String parseProjectFromTopicName(String topicName) { | ||
| 144 | + return TOPIC_PATH_TEMPLATE.parse(topicName).get("project"); | ||
| 173 | 145 | } | |
| 174 | 146 | ||
| 175 | - // =============== | ||
| 176 | - // Factory Methods | ||
| 177 | - // =============== | ||
| 147 | + /** | ||
| 148 | + * Parses the topic from the given fully-qualified path which | ||
| 149 | + * represents a topic resource. | ||
| 150 | + * | ||
| 151 | + * <!-- manual edit --> | ||
| 152 | + * <!-- end manual edit --> | ||
| 153 | + */ | ||
| 154 | + public static final String parseTopicFromTopicName(String topicName) { | ||
| 155 | + return TOPIC_PATH_TEMPLATE.parse(topicName).get("topic"); | ||
| 156 | + } | ||
| 178 | 157 | ||
| 179 | 158 | /** | |
| 180 | 159 | * Constructs an instance of PublisherApi with default settings. | |
| 181 | 160 | * | |
| 182 | 161 | * <!-- manual edit --> | |
| 183 | 162 | * <!-- end manual edit --> | |
| 184 | 163 | */ | |
| 185 | - public static PublisherApi create() throws IOException { | ||
| 164 | + public static final PublisherApi create() throws IOException { | ||
| 186 | 165 | return create(PublisherSettings.create()); | |
| 187 | 166 | } | |
| 188 | 167 | ||
@@ -194,7 +173,7 @@ public static PublisherApi create() throws IOException { | |||
| 194 | 173 | * <!-- manual edit --> | |
| 195 | 174 | * <!-- end manual edit --> | |
| 196 | 175 | */ | |
| 197 | - public static PublisherApi create(PublisherSettings settings) throws IOException { | ||
| 176 | + public static final PublisherApi create(PublisherSettings settings) throws IOException { | ||
| 198 | 177 | return new PublisherApi(settings); | |
| 199 | 178 | } | |
| 200 | 179 | ||
@@ -226,19 +205,17 @@ protected PublisherApi(PublisherSettings settings) throws IOException { | |||
| 226 | 205 | settings.listTopicSubscriptionsMethod().buildPageStreaming(settings); | |
| 227 | 206 | this.deleteTopicCallable = settings.deleteTopicMethod().build(settings); | |
| 228 | 207 | ||
| 229 | - closeables.add( | ||
| 230 | - new Closeable() { | ||
| 231 | - @Override | ||
| 232 | - public void close() throws IOException { | ||
| 233 | - channel.shutdown(); | ||
| 234 | - } | ||
| 235 | - }); | ||
| 208 | + if (settings.shouldAutoCloseChannel()) { | ||
| 209 | + closeables.add( | ||
| 210 | + new Closeable() { | ||
| 211 | + @Override | ||
| 212 | + public void close() throws IOException { | ||
| 213 | + channel.shutdown(); | ||
| 214 | + } | ||
| 215 | + }); | ||
| 216 | + } | ||
| 236 | 217 | } | |
| 237 | 218 | ||
| 238 | - // ============= | ||
| 239 | - // Service Calls | ||
| 240 | - // ============= | ||
| 241 | - | ||
| 242 | 219 | // ----- createTopic ----- | |
| 243 | 220 | ||
| 244 | 221 | // AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing. | |
@@ -255,7 +232,7 @@ public void close() throws IOException { | |||
| 255 | 232 | * signs (`%`). It must be between 3 and 255 characters in length, and it | |
| 256 | 233 | * must not start with `"goog"`. | |
| 257 | 234 | */ | |
| 258 | - public Topic createTopic(String name) { | ||
| 235 | + public final Topic createTopic(String name) { | ||
| 259 | 236 | Topic request = Topic.newBuilder().setName(name).build(); | |
| 260 | 237 | ||
| 261 | 238 | return createTopic(request); | |
@@ -281,7 +258,7 @@ private Topic createTopic(Topic request) { | |||
| 281 | 258 | * <!-- manual edit --> | |
| 282 | 259 | * <!-- end manual edit --> | |
| 283 | 260 | */ | |
| 284 | - public ApiCallable<Topic, Topic> createTopicCallable() { | ||
| 261 | + public final ApiCallable<Topic, Topic> createTopicCallable() { | ||
| 285 | 262 | return createTopicCallable; | |
| 286 | 263 | } | |
| 287 | 264 | ||
@@ -299,7 +276,7 @@ public ApiCallable<Topic, Topic> createTopicCallable() { | |||
| 299 | 276 | * @param topic The messages in the request will be published on this topic. | |
| 300 | 277 | * @param messages The messages to publish. | |
| 301 | 278 | */ | |
| 302 | - public PublishResponse publish(String topic, List<PubsubMessage> messages) { | ||
| 279 | + public final PublishResponse publish(String topic, List<PubsubMessage> messages) { | ||
| 303 | 280 | PublishRequest request = | |
| 304 | 281 | PublishRequest.newBuilder().setTopic(topic).addAllMessages(messages).build(); | |
| 305 | 282 | ||
@@ -330,7 +307,7 @@ public PublishResponse publish(PublishRequest request) { | |||
| 330 | 307 | * <!-- manual edit --> | |
| 331 | 308 | * <!-- end manual edit --> | |
| 332 | 309 | */ | |
| 333 | - public ApiCallable<PublishRequest, PublishResponse> publishCallable() { | ||
| 310 | + public final ApiCallable<PublishRequest, PublishResponse> publishCallable() { | ||
| 334 | 311 | return publishCallable; | |
| 335 | 312 | } | |
| 336 | 313 | ||
@@ -345,7 +322,7 @@ public ApiCallable<PublishRequest, PublishResponse> publishCallable() { | |||
| 345 | 322 | * | |
| 346 | 323 | * @param topic The name of the topic to get. | |
| 347 | 324 | */ | |
| 348 | - public Topic getTopic(String topic) { | ||
| 325 | + public final Topic getTopic(String topic) { | ||
| 349 | 326 | GetTopicRequest request = GetTopicRequest.newBuilder().setTopic(topic).build(); | |
| 350 | 327 | ||
| 351 | 328 | return getTopic(request); | |
@@ -371,7 +348,7 @@ private Topic getTopic(GetTopicRequest request) { | |||
| 371 | 348 | * <!-- manual edit --> | |
| 372 | 349 | * <!-- end manual edit --> | |
| 373 | 350 | */ | |
| 374 | - public ApiCallable<GetTopicRequest, Topic> getTopicCallable() { | ||
| 351 | + public final ApiCallable<GetTopicRequest, Topic> getTopicCallable() { | ||
| 375 | 352 | return getTopicCallable; | |
| 376 | 353 | } | |
| 377 | 354 | ||
@@ -384,7 +361,7 @@ public ApiCallable<GetTopicRequest, Topic> getTopicCallable() { | |||
| 384 | 361 | * <!-- manual edit --> | |
| 385 | 362 | * <!-- end manual edit --> | |
| 386 | 363 | */ | |
| 387 | - public Iterable<Topic> listTopics(String project) { | ||
| 364 | + public final Iterable<Topic> listTopics(String project) { | ||
| 388 | 365 | ListTopicsRequest request = ListTopicsRequest.newBuilder().setProject(project).build(); | |
| 389 | 366 | return listTopics(request); | |
| 390 | 367 | } | |
@@ -398,7 +375,7 @@ public Iterable<Topic> listTopics(String project) { | |||
| 398 | 375 | * | |
| 399 | 376 | * @param request The request object containing all of the parameters for the API call. | |
| 400 | 377 | */ | |
| 401 | - public Iterable<Topic> listTopics(ListTopicsRequest request) { | ||
| 378 | + public final Iterable<Topic> listTopics(ListTopicsRequest request) { | ||
| 402 | 379 | return listTopicsIterableCallable().call(request); | |
| 403 | 380 | } | |
| 404 | 381 | ||
@@ -409,7 +386,7 @@ public Iterable<Topic> listTopics(ListTopicsRequest request) { | |||
| 409 | 386 | * <!-- manual edit --> | |
| 410 | 387 | * <!-- end manual edit --> | |
| 411 | 388 | */ | |
| 412 | - public ApiCallable<ListTopicsRequest, Iterable<Topic>> listTopicsIterableCallable() { | ||
| 389 | + public final ApiCallable<ListTopicsRequest, Iterable<Topic>> listTopicsIterableCallable() { | ||
| 413 | 390 | return listTopicsIterableCallable; | |
| 414 | 391 | } | |
| 415 | 392 | ||
@@ -420,7 +397,7 @@ public ApiCallable<ListTopicsRequest, Iterable<Topic>> listTopicsIterableCallabl | |||
| 420 | 397 | * <!-- manual edit --> | |
| 421 | 398 | * <!-- end manual edit --> | |
| 422 | 399 | */ | |
| 423 | - public ApiCallable<ListTopicsRequest, ListTopicsResponse> listTopicsCallable() { | ||
| 400 | + public final ApiCallable<ListTopicsRequest, ListTopicsResponse> listTopicsCallable() { | ||
| 424 | 401 | return listTopicsCallable; | |
| 425 | 402 | } | |
| 426 | 403 | ||
@@ -433,7 +410,7 @@ public ApiCallable<ListTopicsRequest, ListTopicsResponse> listTopicsCallable() { | |||
| 433 | 410 | * <!-- manual edit --> | |
| 434 | 411 | * <!-- end manual edit --> | |
| 435 | 412 | */ | |
| 436 | - public Iterable<String> listTopicSubscriptions(String topic) { | ||
| 413 | + public final Iterable<String> listTopicSubscriptions(String topic) { | ||
| 437 | 414 | ListTopicSubscriptionsRequest request = | |
| 438 | 415 | ListTopicSubscriptionsRequest.newBuilder().setTopic(topic).build(); | |
| 439 | 416 | return listTopicSubscriptions(request); | |
@@ -448,7 +425,7 @@ public Iterable<String> listTopicSubscriptions(String topic) { | |||
| 448 | 425 | * | |
| 449 | 426 | * @param request The request object containing all of the parameters for the API call. | |
| 450 | 427 | */ | |
| 451 | - public Iterable<String> listTopicSubscriptions(ListTopicSubscriptionsRequest request) { | ||
| 428 | + public final Iterable<String> listTopicSubscriptions(ListTopicSubscriptionsRequest request) { | ||
| 452 | 429 | return listTopicSubscriptionsIterableCallable().call(request); | |
| 453 | 430 | } | |
| 454 | 431 | ||
@@ -459,7 +436,7 @@ public Iterable<String> listTopicSubscriptions(ListTopicSubscriptionsRequest req | |||
| 459 | 436 | * <!-- manual edit --> | |
| 460 | 437 | * <!-- end manual edit --> | |
| 461 | 438 | */ | |
| 462 | - public ApiCallable<ListTopicSubscriptionsRequest, Iterable<String>> | ||
| 439 | + public final ApiCallable<ListTopicSubscriptionsRequest, Iterable<String>> | ||
| 463 | 440 | listTopicSubscriptionsIterableCallable() { | |
| 464 | 441 | return listTopicSubscriptionsIterableCallable; | |
| 465 | 442 | } | |
@@ -471,7 +448,7 @@ public Iterable<String> listTopicSubscriptions(ListTopicSubscriptionsRequest req | |||
| 471 | 448 | * <!-- manual edit --> | |
| 472 | 449 | * <!-- end manual edit --> | |
| 473 | 450 | */ | |
| 474 | - public ApiCallable<ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse> | ||
| 451 | + public final ApiCallable<ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse> | ||
| 475 | 452 | listTopicSubscriptionsCallable() { | |
| 476 | 453 | return listTopicSubscriptionsCallable; | |
| 477 | 454 | } | |
@@ -491,7 +468,7 @@ public Iterable<String> listTopicSubscriptions(ListTopicSubscriptionsRequest req | |||
| 491 | 468 | * | |
| 492 | 469 | * @param topic Name of the topic to delete. | |
| 493 | 470 | */ | |
| 494 | - public void deleteTopic(String topic) { | ||
| 471 | + public final void deleteTopic(String topic) { | ||
| 495 | 472 | DeleteTopicRequest request = DeleteTopicRequest.newBuilder().setTopic(topic).build(); | |
| 496 | 473 | ||
| 497 | 474 | deleteTopic(request); | |
@@ -525,14 +502,10 @@ private void deleteTopic(DeleteTopicRequest request) { | |||
| 525 | 502 | * <!-- manual edit --> | |
| 526 | 503 | * <!-- end manual edit --> | |
| 527 | 504 | */ | |
| 528 | - public ApiCallable<DeleteTopicRequest, Empty> deleteTopicCallable() { | ||
| 505 | + public final ApiCallable<DeleteTopicRequest, Empty> deleteTopicCallable() { | ||
| 529 | 506 | return deleteTopicCallable; | |
| 530 | 507 | } | |
| 531 | 508 | ||
| 532 | - // ======== | ||
| 533 | - // Cleanup | ||
| 534 | - // ======== | ||
| 535 | - | ||
| 536 | 509 | /** | |
| 537 | 510 | * Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately | |
| 538 | 511 | * cancelled. | |
@@ -541,7 +514,7 @@ public ApiCallable<DeleteTopicRequest, Empty> deleteTopicCallable() { | |||
| 541 | 514 | * <!-- end manual edit --> | |
| 542 | 515 | */ | |
| 543 | 516 | @Override | |
| 544 | - public void close() throws Exception { | ||
| 517 | + public final void close() throws Exception { | ||
| 545 | 518 | for (AutoCloseable closeable : closeables) { | |
| 546 | 519 | closeable.close(); | |
| 547 | 520 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments