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

Rename setters/getters/builders for ResourceManager classes to meet proto conventions #1321

Merged
merged 2 commits into from
Oct 21, 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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -512,13 +512,13 @@ if (project != null) {
.addLabel("launch-status", "in-development")
.build()
.replace();
System.out.println("Updated the labels of project " + newProject.projectId()
+ " to be " + newProject.labels());
System.out.println("Updated the labels of project " + newProject.getProjectId()
+ " to be " + newProject.getLabels());
}
Iterator<Project> projectIterator = resourceManager.list().iterateAll();
System.out.println("Projects I can view:");
while (projectIterator.hasNext()) {
System.out.println(projectIterator.next().projectId());
System.out.println(projectIterator.next().getProjectId());
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void run(ResourceManager resourceManager, String... args) {
}
}
Project project =
resourceManager.create(ProjectInfo.builder(projectId).labels(labels).build());
resourceManager.create(ProjectInfo.newBuilder(projectId).setLabels(labels).build());
System.out.printf(
"Successfully created project '%s': %s.%n", projectId, projectDetails(project));
}
Expand Down Expand Up @@ -160,15 +160,15 @@ public String[] getOptionalParams() {
private static String projectDetails(ProjectInfo project) {
return new StringBuilder()
.append("{projectId:")
.append(project.projectId())
.append(project.getProjectId())
.append(", projectNumber:")
.append(project.projectNumber())
.append(project.getProjectNumber())
.append(", createTimeMillis:")
.append(project.createTimeMillis())
.append(project.getCreateTimeMillis())
.append(", state:")
.append(project.state())
.append(project.getState())
.append(", labels:")
.append(project.labels())
.append(project.getLabels())
.append("}")
.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public static void main(String... args) {
Project project = resourceManager.get(projectId);
if (project == null) {
// Create a project.
project = resourceManager.create(ProjectInfo.builder(projectId).build());
project = resourceManager.create(ProjectInfo.newBuilder(projectId).build());
}
System.out.println("Got project " + project.projectId() + " from the server.");
System.out.println("Got project " + project.getProjectId() + " from the server.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ public static void main(String... args) {
.addLabel("launch-status", "in-development")
.build()
.replace();
System.out.println("Updated the labels of project " + newProject.projectId()
+ " to be " + newProject.labels());
System.out.println("Updated the labels of project " + newProject.getProjectId()
+ " to be " + newProject.getLabels());
}

// List all the projects you have permission to view.
Iterator<Project> projectIterator = resourceManager.list().iterateAll();
System.out.println("Projects I can view:");
while (projectIterator.hasNext()) {
System.out.println(projectIterator.next().projectId());
System.out.println(projectIterator.next().getProjectId());
}
}
}
4 changes: 2 additions & 2 deletions google-cloud-resourcemanager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ project ID).

```java
String projectId = "my-globally-unique-project-id"; // Change to a unique project ID
Project project = resourceManager.create(ProjectInfo.builder(projectId).build());
Project project = resourceManager.create(ProjectInfo.newBuilder(projectId).build());
```

Note that the return value from `create` is a `Project` that includes additional read-only
Expand Down Expand Up @@ -159,7 +159,7 @@ Then add the following code to print a list of projects you can view:
Iterator<Project> projectIterator = resourceManager.list().iterateAll();
System.out.println("Projects I can view:");
while (projectIterator.hasNext()) {
System.out.println(projectIterator.next().projectId());
System.out.println(projectIterator.next().getProjectId());
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ abstract class Option implements Serializable {
this.value = value;
}

ResourceManagerRpc.Option rpcOption() {
ResourceManagerRpc.Option getRpcOption() {
return rpcOption;
}

Object value() {
Object getValue() {
return value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,26 @@ public static class Builder extends ProjectInfo.Builder {
}

@Override
@Deprecated
public Builder name(String name) {
infoBuilder.name(name);
return setName(name);
}

@Override
public Builder setName(String name) {
infoBuilder.setName(name);
return this;
}

@Override
@Deprecated
public Builder projectId(String projectId) {
infoBuilder.projectId(projectId);
return setProjectId(projectId);
}

@Override
public Builder setProjectId(String projectId) {
infoBuilder.setProjectId(projectId);
return this;
}

Expand All @@ -84,32 +96,38 @@ public Builder clearLabels() {
}

@Override
@Deprecated
public Builder labels(Map<String, String> labels) {
infoBuilder.labels(labels);
return setLabels(labels);
}

@Override
public Builder setLabels(Map<String, String> labels) {
infoBuilder.setLabels(labels);
return this;
}

@Override
Builder projectNumber(Long projectNumber) {
infoBuilder.projectNumber(projectNumber);
Builder setProjectNumber(Long projectNumber) {
infoBuilder.setProjectNumber(projectNumber);
return this;
}

@Override
Builder state(State state) {
infoBuilder.state(state);
Builder setState(State state) {
infoBuilder.setState(state);
return this;
}

@Override
Builder createTimeMillis(Long createTimeMillis) {
infoBuilder.createTimeMillis(createTimeMillis);
Builder setCreateTimeMillis(Long createTimeMillis) {
infoBuilder.setCreateTimeMillis(createTimeMillis);
return this;
}

@Override
Builder parent(ResourceId parent) {
infoBuilder.parent(parent);
Builder setParent(ResourceId parent) {
infoBuilder.setParent(parent);
return this;
}

Expand All @@ -128,7 +146,15 @@ public Project build() {
/**
* Returns the {@link ResourceManager} service object associated with this Project.
*/
@Deprecated
public ResourceManager resourceManager() {
return getResourceManager();
}

/**
* Returns the {@link ResourceManager} service object associated with this Project.
*/
public ResourceManager getResourceManager() {
return resourceManager;
}

Expand All @@ -140,7 +166,7 @@ public ResourceManager resourceManager() {
* @throws ResourceManagerException upon failure
*/
public Project reload() {
return resourceManager.get(projectId());
return resourceManager.get(getProjectId());
}

/**
Expand All @@ -166,7 +192,7 @@ public Project reload() {
* Resource Manager delete</a>
*/
public void delete() {
resourceManager.delete(projectId());
resourceManager.delete(getProjectId());
}

/**
Expand All @@ -183,7 +209,7 @@ public void delete() {
* Resource Manager undelete</a>
*/
public void undelete() {
resourceManager.undelete(projectId());
resourceManager.undelete(getProjectId());
}

/**
Expand Down Expand Up @@ -212,7 +238,7 @@ public Project replace() {
* Resource Manager getIamPolicy</a>
*/
public Policy getPolicy() {
return resourceManager.getPolicy(projectId());
return resourceManager.getPolicy(getProjectId());
}

/**
Expand All @@ -227,7 +253,7 @@ public Policy getPolicy() {
* Resource Manager setIamPolicy</a>
*/
public Policy replacePolicy(Policy newPolicy) {
return resourceManager.replacePolicy(projectId(), newPolicy);
return resourceManager.replacePolicy(getProjectId(), newPolicy);
}

/**
Expand All @@ -250,7 +276,7 @@ public Policy replacePolicy(Policy newPolicy) {
* Services</a>
*/
List<Boolean> testPermissions(List<String> permissions) {
return resourceManager.testPermissions(projectId(), permissions);
return resourceManager.testPermissions(getProjectId(), permissions);
}

@Override
Expand Down
Loading