Skip to content

Commit

Permalink
Run google-java-format on all artifacts (googleapis#4121)
Browse files Browse the repository at this point in the history
* Run google-java-format on all artifats

* Format some missed files

* Add more missed files

* Fix formatting issues from the merge
  • Loading branch information
chingor13 authored Nov 30, 2018
1 parent b91553a commit b999bff
Show file tree
Hide file tree
Showing 23 changed files with 571 additions and 523 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@

import com.google.cloud.resourcemanager.spi.v1beta1.ResourceManagerRpc;
import com.google.common.base.MoreObjects;

import java.io.Serializable;
import java.util.Objects;

/**
* Base class for Resource Manager operation options.
*/
/** Base class for Resource Manager operation options. */
abstract class Option implements Serializable {

private static final long serialVersionUID = 2655177550880762967L;
Expand All @@ -53,8 +50,7 @@ public boolean equals(Object obj) {
return false;
}
Option other = (Option) obj;
return Objects.equals(rpcOption, other.rpcOption)
&& Objects.equals(value, other.value);
return Objects.equals(rpcOption, other.rpcOption) && Objects.equals(value, other.value);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.google.common.base.Function;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
Expand Down Expand Up @@ -55,13 +54,17 @@ protected Policy fromPb(com.google.api.services.cloudresourcemanager.model.Polic
Map<Role, Set<Identity>> bindings = new HashMap<>();
if (policyPb.getBindings() != null) {
for (Binding bindingPb : policyPb.getBindings()) {
bindings.put(Role.of(bindingPb.getRole()), ImmutableSet.copyOf(
Lists.transform(bindingPb.getMembers(), new Function<String, Identity>() {
@Override
public Identity apply(String s) {
return IDENTITY_VALUE_OF_FUNCTION.apply(s);
}
})));
bindings.put(
Role.of(bindingPb.getRole()),
ImmutableSet.copyOf(
Lists.transform(
bindingPb.getMembers(),
new Function<String, Identity>() {
@Override
public Identity apply(String s) {
return IDENTITY_VALUE_OF_FUNCTION.apply(s);
}
})));
}
}
return new Builder(bindings, policyPb.getEtag(), policyPb.getVersion()).build();
Expand All @@ -71,18 +74,19 @@ public Identity apply(String s) {
protected com.google.api.services.cloudresourcemanager.model.Policy toPb(Policy policy) {
com.google.api.services.cloudresourcemanager.model.Policy policyPb =
new com.google.api.services.cloudresourcemanager.model.Policy();
List<Binding> bindingPbList =
new LinkedList<>();
List<Binding> bindingPbList = new LinkedList<>();
for (Map.Entry<Role, Set<Identity>> binding : policy.getBindings().entrySet()) {
Binding bindingPb = new Binding();
bindingPb.setRole(binding.getKey().getValue());
bindingPb.setMembers(
Lists.transform(new ArrayList<>(binding.getValue()), new Function<Identity, String>() {
@Override
public String apply(Identity identity) {
return IDENTITY_STR_VALUE_FUNCTION.apply(identity);
}
}));
Lists.transform(
new ArrayList<>(binding.getValue()),
new Function<Identity, String>() {
@Override
public String apply(Identity identity) {
return IDENTITY_STR_VALUE_FUNCTION.apply(identity);
}
}));
bindingPbList.add(bindingPb);
}
policyPb.setBindings(bindingPbList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static com.google.common.base.Preconditions.checkNotNull;

import com.google.cloud.Policy;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.List;
Expand All @@ -41,9 +40,7 @@ public class Project extends ProjectInfo {
private final ResourceManagerOptions options;
private transient ResourceManager resourceManager;

/**
* Builder for {@code Project}.
*/
/** Builder for {@code Project}. */
public static class Builder extends ProjectInfo.Builder {
private final ResourceManager resourceManager;
private final ProjectInfo.BuilderImpl infoBuilder;
Expand All @@ -53,14 +50,12 @@ public static class Builder extends ProjectInfo.Builder {
this.infoBuilder = new ProjectInfo.BuilderImpl(project);
}


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


@Override
public Builder setProjectId(String projectId) {
infoBuilder.setProjectId(projectId);
Expand All @@ -85,7 +80,6 @@ public Builder clearLabels() {
return this;
}


@Override
public Builder setLabels(Map<String, String> labels) {
infoBuilder.setLabels(labels);
Expand Down Expand Up @@ -128,17 +122,13 @@ public Project build() {
this.options = resourceManager.getOptions();
}


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

/**
* Fetches the project's latest information. Returns {@code null} if the project does not
* exist.
* Fetches the project's latest information. Returns {@code null} if the project does not exist.
*
* @return Project containing the project's updated metadata or {@code null} if not found
* @throws ResourceManagerException upon failure
Expand All @@ -151,18 +141,20 @@ public Project reload() {
* Marks the project identified by the specified project ID for deletion.
*
* <p>This method will only affect the project if the following criteria are met:
*
* <ul>
* <li>The project does not have a billing account associated with it.
* <li>The project has a lifecycle state of {@link ProjectInfo.State#ACTIVE}.
* <li>The project does not have a billing account associated with it.
* <li>The project has a lifecycle state of {@link ProjectInfo.State#ACTIVE}.
* </ul>
*
* This method changes the project's lifecycle state from {@link ProjectInfo.State#ACTIVE} to
* {@link ProjectInfo.State#DELETE_REQUESTED}. The deletion starts at an unspecified time, at
* which point the lifecycle state changes to {@link ProjectInfo.State#DELETE_IN_PROGRESS}. Until
* the deletion completes, you can check the lifecycle state checked by retrieving the project
* with {@link ResourceManager#get}, and the project remains visible to
* {@link ResourceManager#list}. However, you cannot update the project. After the deletion
* completes, the project is not retrievable by the {@link ResourceManager#get} and
* {@link ResourceManager#list} methods. The caller must have modify permissions for this project.
* with {@link ResourceManager#get}, and the project remains visible to {@link
* ResourceManager#list}. However, you cannot update the project. After the deletion completes,
* the project is not retrievable by the {@link ResourceManager#get} and {@link
* ResourceManager#list} methods. The caller must have modify permissions for this project.
*
* @throws ResourceManagerException upon failure
* @see <a href=
Expand All @@ -176,10 +168,10 @@ public void delete() {
/**
* Restores the project identified by the specified project ID.
*
* <p>You can only use this method for a project that has a lifecycle state of
* {@link ProjectInfo.State#DELETE_REQUESTED}. After deletion starts, as indicated by a lifecycle
* state of {@link ProjectInfo.State#DELETE_IN_PROGRESS}, the project cannot be restored. The
* caller must have modify permissions for this project.
* <p>You can only use this method for a project that has a lifecycle state of {@link
* ProjectInfo.State#DELETE_REQUESTED}. After deletion starts, as indicated by a lifecycle state
* of {@link ProjectInfo.State#DELETE_IN_PROGRESS}, the project cannot be restored. The caller
* must have modify permissions for this project.
*
* @throws ResourceManagerException upon failure (including when the project can't be restored)
* @see <a href=
Expand Down Expand Up @@ -239,7 +231,7 @@ public Policy replacePolicy(Policy newPolicy) {
* if you're using Google Cloud Platform directly to manage permissions. This method is intended
* for integration with your proprietary software, such as a customized graphical user interface.
* For example, the Cloud Platform Console tests IAM permissions internally to determine which UI
* should be available to the logged-in user. Each service that supports IAM lists the possible
* should be available to the logged-in user. Each service that supports IAM lists the possible
* permissions; see the <i>Supported Cloud Platform services</i> page below for links to these
* lists.
*
Expand All @@ -249,9 +241,8 @@ public Policy replacePolicy(Policy newPolicy) {
* @see <a href=
* "https://cloud.google.com/resource-manager/reference/rest/v1beta1/projects/testIamPermissions">
* Resource Manager testIamPermissions</a>
* @see <a href=
* "https://cloud.google.com/iam/#supported_cloud_platform_services">Supported Cloud Platform
* Services</a>
* @see <a href= "https://cloud.google.com/iam/#supported_cloud_platform_services">Supported Cloud
* Platform Services</a>
*/
List<Boolean> testPermissions(List<String> permissions) {
return resourceManager.testPermissions(getProjectId(), permissions);
Expand All @@ -271,8 +262,7 @@ public final boolean equals(Object obj) {
return false;
}
Project other = (Project) obj;
return Objects.equals(toPb(), other.toPb())
&& Objects.equals(options, other.options);
return Objects.equals(toPb(), other.toPb()) && Objects.equals(options, other.options);
}

@Override
Expand All @@ -285,7 +275,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE
this.resourceManager = options.getService();
}

static Project fromPb(ResourceManager resourceManager,
static Project fromPb(
ResourceManager resourceManager,
com.google.api.services.cloudresourcemanager.model.Project answer) {
ProjectInfo info = ProjectInfo.fromPb(answer);
return new Project(resourceManager, new ProjectInfo.BuilderImpl(info));
Expand Down
Loading

0 comments on commit b999bff

Please sign in to comment.