Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update with latest surface fixes based Java export review. #800

Merged
merged 2 commits into from
Mar 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@
*/
@javax.annotation.Generated("by GAPIC")
public class PublisherApi implements AutoCloseable {
// ========
// Members
// ========

private final ManagedChannel channel;
private final List<AutoCloseable> closeables = new ArrayList<>();

Expand All @@ -84,105 +80,88 @@ public class PublisherApi implements AutoCloseable {
listTopicSubscriptionsIterableCallable;
private final ApiCallable<DeleteTopicRequest, Empty> deleteTopicCallable;

public static class ResourceNames {

// =======================
// ResourceNames Constants
// =======================

/**
* A PathTemplate representing the fully-qualified path to represent
* a project resource.
*
* <!-- manual edit -->
* <!-- end manual edit -->
*/
private static final PathTemplate PROJECT_PATH_TEMPLATE =
PathTemplate.create("projects/{project}");

/**
* A PathTemplate representing the fully-qualified path to represent
* a topic resource.
*
* <!-- manual edit -->
* <!-- end manual edit -->
*/
private static final PathTemplate TOPIC_PATH_TEMPLATE =
PathTemplate.create("projects/{project}/topics/{topic}");

private ResourceNames() {}

// ==============================
// Resource Name Helper Functions
// ==============================

/**
* Formats a string containing the fully-qualified path to represent
* a project resource.
*
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public static final String formatProjectPath(String project) {
return PROJECT_PATH_TEMPLATE.instantiate("project", project);
}
/**
* A PathTemplate representing the fully-qualified path to represent
* a project resource.
*
* <!-- manual edit -->

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

* <!-- end manual edit -->
*/
private static final PathTemplate PROJECT_PATH_TEMPLATE =
PathTemplate.create("projects/{project}");

/**
* Formats a string containing the fully-qualified path to represent
* a topic resource.
*
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public static final String formatTopicPath(String project, String topic) {
return TOPIC_PATH_TEMPLATE.instantiate("project", project, "topic", topic);
}
/**
* A PathTemplate representing the fully-qualified path to represent
* a topic resource.
*
* <!-- manual edit -->
* <!-- end manual edit -->
*/
private static final PathTemplate TOPIC_PATH_TEMPLATE =
PathTemplate.create("projects/{project}/topics/{topic}");

/**
* Parses the project from the given fully-qualified path which
* represents a project resource.
*
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public static final String parseProjectFromProjectPath(String projectPath) {
return PROJECT_PATH_TEMPLATE.parse(projectPath).get("project");
}
/**
* Formats a string containing the fully-qualified path to represent
* a project resource.
*
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public static final String formatProjectName(String project) {
return PROJECT_PATH_TEMPLATE.instantiate("project", project);
}

/**
* Parses the project from the given fully-qualified path which
* represents a topic resource.
*
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public static final String parseProjectFromTopicPath(String topicPath) {
return TOPIC_PATH_TEMPLATE.parse(topicPath).get("project");
}
/**
* Formats a string containing the fully-qualified path to represent
* a topic resource.
*
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public static final String formatTopicName(String project, String topic) {
return TOPIC_PATH_TEMPLATE.instantiate("project", project, "topic", topic);
}

/**
* Parses the topic from the given fully-qualified path which
* represents a topic resource.
*
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public static final String parseTopicFromTopicPath(String topicPath) {
return TOPIC_PATH_TEMPLATE.parse(topicPath).get("topic");
}
/**
* Parses the project from the given fully-qualified path which
* represents a project resource.
*
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public static final String parseProjectFromProjectName(String projectName) {
return PROJECT_PATH_TEMPLATE.parse(projectName).get("project");
}

/**
* Parses the project from the given fully-qualified path which
* represents a topic resource.
*
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public static final String parseProjectFromTopicName(String topicName) {
return TOPIC_PATH_TEMPLATE.parse(topicName).get("project");
}

// ===============
// Factory Methods
// ===============
/**
* Parses the topic from the given fully-qualified path which
* represents a topic resource.
*
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public static final String parseTopicFromTopicName(String topicName) {
return TOPIC_PATH_TEMPLATE.parse(topicName).get("topic");
}

/**
* Constructs an instance of PublisherApi with default settings.
*
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public static PublisherApi create() throws IOException {
public static final PublisherApi create() throws IOException {
return create(PublisherSettings.create());
}

Expand All @@ -194,7 +173,7 @@ public static PublisherApi create() throws IOException {
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public static PublisherApi create(PublisherSettings settings) throws IOException {
public static final PublisherApi create(PublisherSettings settings) throws IOException {
return new PublisherApi(settings);
}

Expand Down Expand Up @@ -226,19 +205,17 @@ protected PublisherApi(PublisherSettings settings) throws IOException {
settings.listTopicSubscriptionsMethod().buildPageStreaming(settings);
this.deleteTopicCallable = settings.deleteTopicMethod().build(settings);

closeables.add(
new Closeable() {
@Override
public void close() throws IOException {
channel.shutdown();
}
});
if (settings.shouldAutoCloseChannel()) {
closeables.add(
new Closeable() {
@Override
public void close() throws IOException {
channel.shutdown();
}
});
}
}

// =============
// Service Calls
// =============

// ----- createTopic -----

// AUTO-GENERATED DOCUMENTATION AND METHOD - see instructions at the top of the file for editing.
Expand All @@ -255,7 +232,7 @@ public void close() throws IOException {
* signs (`%`). It must be between 3 and 255 characters in length, and it
* must not start with `"goog"`.
*/
public Topic createTopic(String name) {
public final Topic createTopic(String name) {
Topic request = Topic.newBuilder().setName(name).build();

return createTopic(request);
Expand All @@ -281,7 +258,7 @@ private Topic createTopic(Topic request) {
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public ApiCallable<Topic, Topic> createTopicCallable() {
public final ApiCallable<Topic, Topic> createTopicCallable() {
return createTopicCallable;
}

Expand All @@ -299,7 +276,7 @@ public ApiCallable<Topic, Topic> createTopicCallable() {
* @param topic The messages in the request will be published on this topic.
* @param messages The messages to publish.
*/
public PublishResponse publish(String topic, List<PubsubMessage> messages) {
public final PublishResponse publish(String topic, List<PubsubMessage> messages) {
PublishRequest request =
PublishRequest.newBuilder().setTopic(topic).addAllMessages(messages).build();

Expand Down Expand Up @@ -330,7 +307,7 @@ public PublishResponse publish(PublishRequest request) {
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public ApiCallable<PublishRequest, PublishResponse> publishCallable() {
public final ApiCallable<PublishRequest, PublishResponse> publishCallable() {
return publishCallable;
}

Expand All @@ -345,7 +322,7 @@ public ApiCallable<PublishRequest, PublishResponse> publishCallable() {
*
* @param topic The name of the topic to get.
*/
public Topic getTopic(String topic) {
public final Topic getTopic(String topic) {
GetTopicRequest request = GetTopicRequest.newBuilder().setTopic(topic).build();

return getTopic(request);
Expand All @@ -371,7 +348,7 @@ private Topic getTopic(GetTopicRequest request) {
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public ApiCallable<GetTopicRequest, Topic> getTopicCallable() {
public final ApiCallable<GetTopicRequest, Topic> getTopicCallable() {
return getTopicCallable;
}

Expand All @@ -384,7 +361,7 @@ public ApiCallable<GetTopicRequest, Topic> getTopicCallable() {
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public Iterable<Topic> listTopics(String project) {
public final Iterable<Topic> listTopics(String project) {
ListTopicsRequest request = ListTopicsRequest.newBuilder().setProject(project).build();
return listTopics(request);
}
Expand All @@ -398,7 +375,7 @@ public Iterable<Topic> listTopics(String project) {
*
* @param request The request object containing all of the parameters for the API call.
*/
public Iterable<Topic> listTopics(ListTopicsRequest request) {
public final Iterable<Topic> listTopics(ListTopicsRequest request) {
return listTopicsIterableCallable().call(request);
}

Expand All @@ -409,7 +386,7 @@ public Iterable<Topic> listTopics(ListTopicsRequest request) {
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public ApiCallable<ListTopicsRequest, Iterable<Topic>> listTopicsIterableCallable() {
public final ApiCallable<ListTopicsRequest, Iterable<Topic>> listTopicsIterableCallable() {
return listTopicsIterableCallable;
}

Expand All @@ -420,7 +397,7 @@ public ApiCallable<ListTopicsRequest, Iterable<Topic>> listTopicsIterableCallabl
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public ApiCallable<ListTopicsRequest, ListTopicsResponse> listTopicsCallable() {
public final ApiCallable<ListTopicsRequest, ListTopicsResponse> listTopicsCallable() {
return listTopicsCallable;
}

Expand All @@ -433,7 +410,7 @@ public ApiCallable<ListTopicsRequest, ListTopicsResponse> listTopicsCallable() {
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public Iterable<String> listTopicSubscriptions(String topic) {
public final Iterable<String> listTopicSubscriptions(String topic) {
ListTopicSubscriptionsRequest request =
ListTopicSubscriptionsRequest.newBuilder().setTopic(topic).build();
return listTopicSubscriptions(request);
Expand All @@ -448,7 +425,7 @@ public Iterable<String> listTopicSubscriptions(String topic) {
*
* @param request The request object containing all of the parameters for the API call.
*/
public Iterable<String> listTopicSubscriptions(ListTopicSubscriptionsRequest request) {
public final Iterable<String> listTopicSubscriptions(ListTopicSubscriptionsRequest request) {
return listTopicSubscriptionsIterableCallable().call(request);
}

Expand All @@ -459,7 +436,7 @@ public Iterable<String> listTopicSubscriptions(ListTopicSubscriptionsRequest req
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public ApiCallable<ListTopicSubscriptionsRequest, Iterable<String>>
public final ApiCallable<ListTopicSubscriptionsRequest, Iterable<String>>
listTopicSubscriptionsIterableCallable() {
return listTopicSubscriptionsIterableCallable;
}
Expand All @@ -471,7 +448,7 @@ public Iterable<String> listTopicSubscriptions(ListTopicSubscriptionsRequest req
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public ApiCallable<ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse>
public final ApiCallable<ListTopicSubscriptionsRequest, ListTopicSubscriptionsResponse>
listTopicSubscriptionsCallable() {
return listTopicSubscriptionsCallable;
}
Expand All @@ -491,7 +468,7 @@ public Iterable<String> listTopicSubscriptions(ListTopicSubscriptionsRequest req
*
* @param topic Name of the topic to delete.
*/
public void deleteTopic(String topic) {
public final void deleteTopic(String topic) {
DeleteTopicRequest request = DeleteTopicRequest.newBuilder().setTopic(topic).build();

deleteTopic(request);
Expand Down Expand Up @@ -525,14 +502,10 @@ private void deleteTopic(DeleteTopicRequest request) {
* <!-- manual edit -->
* <!-- end manual edit -->
*/
public ApiCallable<DeleteTopicRequest, Empty> deleteTopicCallable() {
public final ApiCallable<DeleteTopicRequest, Empty> deleteTopicCallable() {
return deleteTopicCallable;
}

// ========
// Cleanup
// ========

/**
* Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately
* cancelled.
Expand All @@ -541,7 +514,7 @@ public ApiCallable<DeleteTopicRequest, Empty> deleteTopicCallable() {
* <!-- end manual edit -->
*/
@Override
public void close() throws Exception {
public final void close() throws Exception {
for (AutoCloseable closeable : closeables) {
closeable.close();
}
Expand Down
Loading