You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ad...@apache.org on 2014/10/30 17:41:12 UTC
[3/4] Use AutoValue to reduce bulk of Google Storage value types.
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b8670b16/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ListObjectAccessControls.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ListObjectAccessControls.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ListObjectAccessControls.java
deleted file mode 100644
index 2e2944d..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ListObjectAccessControls.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jclouds.googlecloudstorage.domain;
-
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.Objects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Set;
-
-import org.jclouds.googlecloudstorage.domain.Resource.Kind;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Objects.ToStringHelper;
-import com.google.common.collect.ImmutableSet;
-
-public class ListObjectAccessControls {
-
- protected final Kind kind;
- protected final Set<ObjectAccessControls> items;
-
- protected ListObjectAccessControls(Kind kind, Set<ObjectAccessControls> items) {
-
- this.kind = checkNotNull(kind, "kind");
- this.items = checkNotNull(items, "items");
- }
-
- public Kind getKind() {
- return kind;
- }
-
- public Set<ObjectAccessControls> getItems() {
- return items;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(kind, items);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null || getClass() != obj.getClass())
- return false;
- ListObjectAccessControls that = ListObjectAccessControls.class.cast(obj);
- return equal(this.kind, that.kind) && equal(this.items, that.items);
-
- }
-
- protected ToStringHelper string() {
- return toStringHelper(this).omitNullValues().add("kind", kind).add("items", items);
- }
-
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public Builder toBuilder() {
- return new Builder().fromListObjectAccessControls(this);
- }
-
- public static final class Builder {
-
- private Kind kind;
- private ImmutableSet.Builder<ObjectAccessControls> items = ImmutableSet.builder();
-
- public Builder kind(Kind kind) {
- this.kind = checkNotNull(kind , "kind");
- return this;
- }
-
- public Builder addItems(ObjectAccessControls bucketAccessControls) {
- this.items.add(bucketAccessControls);
- return this;
- }
-
- public Builder items(Set<ObjectAccessControls> items) {
- this.items.addAll(items);
- return this;
- }
-
- public ListObjectAccessControls build() {
- return new ListObjectAccessControls(this.kind, items.build());
- }
-
- public Builder fromListObjectAccessControls(ListObjectAccessControls in) {
- return this.kind(in.getKind()).items(in.getItems());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b8670b16/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ListPage.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ListPage.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ListPage.java
index d01add6..147e3c7 100644
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ListPage.java
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ListPage.java
@@ -16,136 +16,43 @@
*/
package org.jclouds.googlecloudstorage.domain;
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.Objects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
+import java.util.List;
-import java.beans.ConstructorProperties;
-import java.util.Iterator;
-import java.util.Set;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.googlecloudstorage.domain.Resource.Kind;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Optional;
+import com.google.common.collect.ForwardingList;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
/**
* The collection returned from any <code>listFirstPage()</code> method.
*/
-public class ListPage<T> extends IterableWithMarker<T> {
+public class ListPage<T> extends ForwardingList<T> {
- private final Kind kind;
+ private final List<T> items;
private final String nextPageToken;
- private final Iterable<T> items;
- private final Set<String> prefixes;
+ private final List<String> prefixes;
- @ConstructorProperties({ "kind", "nextPageToken", "items", "prefixes" })
- protected ListPage(Kind kind, String nextPageToken, Iterable<T> items, Set<String> prefixes) {
+ public static <T> ListPage<T> create(Iterable<T> items, String nextPageToken, List<String> prefixes) {
+ return new ListPage<T>(items, nextPageToken, prefixes);
+ }
- this.kind = checkNotNull(kind, "kind");
+ @SerializedNames({ "items", "nextPageToken", "prefixes" })
+ protected ListPage(Iterable<T> items, String nextPageToken, List<String> prefixes) {
+ this.items = items != null ? ImmutableList.copyOf(items) : ImmutableList.<T>of();
this.nextPageToken = nextPageToken;
- this.items = items != null ? ImmutableList.copyOf(items) : ImmutableList.<T> of();
- this.prefixes = prefixes != null ? prefixes : ImmutableSet.<String> of();
- }
-
- public Kind getKind() {
- return kind;
+ this.prefixes = prefixes != null ? prefixes : ImmutableList.<String>of();
}
- public String getNextPageToken() {
+ @Nullable public String nextPageToken() {
return nextPageToken;
}
- public Set<String> getPrefixes() {
+ public List<String> prefixes() {
return prefixes;
}
- @Override
- public Optional<Object> nextMarker() {
- return Optional.<Object> fromNullable(nextPageToken);
- }
-
- @Override
- public Iterator<T> iterator() {
- return checkNotNull(items, "items").iterator();
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(kind, items);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null || getClass() != obj.getClass())
- return false;
- ListPage<?> that = ListPage.class.cast(obj);
- return equal(this.kind, that.kind) && equal(this.items, that.items);
- }
-
- protected Objects.ToStringHelper string() {
- return toStringHelper(this).omitNullValues().add("kind", kind).add("nextPageToken", nextPageToken)
- .add("items", items);
- }
-
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static <T> Builder<T> builder() {
- return new Builder<T>();
- }
-
- public Builder<T> toBuilder() {
- return new Builder<T>().fromPagedList(this);
- }
-
- public static final class Builder<T> {
-
- private Kind kind;
- private String nextPageToken;
- private ImmutableList.Builder<T> items = ImmutableList.builder();
- private ImmutableSet.Builder<String> prefixes = ImmutableSet.builder();
-
- public Builder<T> kind(Kind kind) {
- this.kind = kind;
- return this;
- }
-
- public Builder<T> addItem(T item) {
- this.items.add(item);
- return this;
- }
-
- public Builder<T> items(Iterable<T> items) {
- this.items.addAll(items);
- return this;
- }
-
- public Builder<T> prefixes(Set<String> prefixes) {
- this.prefixes.addAll(prefixes);
- return this;
- }
-
- public Builder<T> nextPageToken(String nextPageToken) {
- this.nextPageToken = nextPageToken;
- return this;
- }
-
- public ListPage<T> build() {
- return new ListPage<T>(kind, nextPageToken, items.build(), prefixes.build());
- }
-
- public Builder<T> fromPagedList(ListPage<T> in) {
- return this.kind(in.getKind()).nextPageToken((String) in.nextMarker().orNull()).items(in)
- .prefixes(in.getPrefixes());
-
- }
+ @Override protected List<T> delegate() {
+ return items;
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b8670b16/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ObjectAccessControls.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ObjectAccessControls.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ObjectAccessControls.java
index 3cf559f..6d34f4c 100644
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ObjectAccessControls.java
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ObjectAccessControls.java
@@ -16,132 +16,69 @@
*/
package org.jclouds.googlecloudstorage.domain;
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.net.URI;
-
import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.ObjectRole;
-import org.jclouds.googlecloudstorage.domain.internal.ProjectTeam;
import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
-import com.google.common.base.Objects;
+import com.google.auto.value.AutoValue;
/**
* Represents a Object Access Control Resource.
*
* @see <a href= "https://developers.google.com/storage/docs/json_api/v1/objectAccessControls"/>
*/
-public class ObjectAccessControls extends Resource {
-
- protected final String bucket;
- protected final String entity;
- protected final String object;
- protected final Long generation;
- protected final ObjectRole role;
- protected final String email;
- protected final String entityId;
- protected final String domain;
- protected final ProjectTeam projectTeam;
-
- protected ObjectAccessControls(@Nullable String id, @Nullable URI selfLink, @Nullable String etag, String bucket,
- @Nullable String object, @Nullable Long generation, String entity, @Nullable String entityId,
- ObjectRole role, @Nullable String email, @Nullable String domain, @Nullable ProjectTeam projectTeam) {
- super(Kind.OBJECT_ACCESS_CONTROL, id, selfLink, etag);
-
- this.bucket = bucket;
- this.entity = checkNotNull(entity, "entity");
- this.object = object;
- this.generation = generation;
- this.entityId = entityId;
- this.role = checkNotNull(role, "role");
- this.email = email;
- this.domain = domain;
- this.projectTeam = projectTeam;
- }
+@AutoValue
+public abstract class ObjectAccessControls {
+ private final String kind = "storage#objectAccessControl";
- public String getBucket() {
- return bucket;
- }
+ @Nullable public abstract String id();
- public String getEntity() {
- return entity;
- }
+ @Nullable public abstract String bucket();
- public ObjectRole getRole() {
- return role;
- }
+ @Nullable public abstract String object();
- public String getEmail() {
- return email;
- }
+ @Nullable public abstract Long generation();
- public String getObject() {
- return object;
- }
+ public abstract String entity();
- public Long getGeneration() {
- return generation;
- }
+ @Nullable public abstract String entityId();
- public String getDomain() {
- return domain;
- }
+ public abstract ObjectRole role();
- public String getEntityId() {
- return entityId;
- }
+ @Nullable public abstract String email();
- public ProjectTeam getProjectTeam() {
- return projectTeam;
- }
+ @Nullable public abstract String domain();
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null || getClass() != obj.getClass())
- return false;
- ObjectAccessControls that = ObjectAccessControls.class.cast(obj);
- return equal(this.kind, that.kind) && equal(this.bucket, that.bucket) && equal(this.object, that.object)
- && equal(this.entity, that.entity) && equal(this.id , that.id);
- }
+ @Nullable public abstract ProjectTeam projectTeam();
- protected Objects.ToStringHelper string() {
- return super.string().omitNullValues().add("bucket", bucket).add("entity", entity).add("entityId", entityId)
- .add("object", object).add("generation", generation).add("role", role).add("email", email)
- .add("domain", domain).add("projectTeam", projectTeam);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(kind, bucket, object, entity);
- }
-
- @Override
- public String toString() {
- return string().toString();
+ @SerializedNames(
+ { "id", "bucket", "object", "generation", "entity", "entityId", "role", "email", "domain", "projectTeam" })
+ public static ObjectAccessControls create(String id, String bucket, String object, Long generation, String entity,
+ String entityId, ObjectRole role, String email, String domain, ProjectTeam projectTeam) {
+ return new AutoValue_ObjectAccessControls(id, bucket, object, generation, entity, entityId, role, email, domain,
+ projectTeam);
}
public static Builder builder() {
return new Builder();
}
- public Builder toBuilder() {
- return new Builder().fromObjectAccessControls(this);
- }
-
- public static final class Builder extends Resource.Builder<Builder> {
-
- protected String object;
- protected Long generation;
- protected String bucket;
- protected String entity;
- protected String entityId;
- protected ObjectRole role;
- protected String email;
- protected String domain;
- protected ProjectTeam projectTeam;
+ public static final class Builder {
+ private String id;
+ private String object;
+ private Long generation;
+ private String bucket;
+ private String entity;
+ private String entityId;
+ private ObjectRole role;
+ private String email;
+ private String domain;
+ private ProjectTeam projectTeam;
+
+ public Builder id(String id) {
+ this.id = id;
+ return this;
+ }
public Builder bucket(String bucket) {
this.bucket = bucket;
@@ -189,19 +126,8 @@ public class ObjectAccessControls extends Resource {
}
public ObjectAccessControls build() {
- return new ObjectAccessControls(super.id, super.selfLink, super.etag, bucket, object, generation, entity,
- entityId, role, email, domain, projectTeam);
- }
-
- public Builder fromObjectAccessControls(ObjectAccessControls in) {
- return super.fromResource(in).bucket(in.getBucket()).entity(in.getEntity()).entityId(in.getEntityId())
- .role(in.getRole()).email(in.getEmail()).domain(in.getDomain()).object(in.getObject())
- .generation(in.getGeneration()).projectTeam(in.getProjectTeam());
- }
-
- @Override
- protected Builder self() {
- return this;
+ return ObjectAccessControls
+ .create(id, bucket, object, generation, entity, entityId, role, email, domain, projectTeam);
}
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b8670b16/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/Owner.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/Owner.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/Owner.java
new file mode 100644
index 0000000..57137e6
--- /dev/null
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/Owner.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecloudstorage.domain;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
+
+import com.google.auto.value.AutoValue;
+
+@AutoValue
+public abstract class Owner {
+ public abstract String entity();
+
+ @Nullable public abstract String entityId();
+
+ @SerializedNames({"entity", "entityId"})
+ public static Owner create(String entity, String entityId) {
+ return new AutoValue_Owner(entity, entityId);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b8670b16/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ProjectTeam.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ProjectTeam.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ProjectTeam.java
new file mode 100644
index 0000000..538e4c8
--- /dev/null
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ProjectTeam.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.googlecloudstorage.domain;
+
+import org.jclouds.json.SerializedNames;
+
+import com.google.auto.value.AutoValue;
+
+/**
+ * The bucket's logging configuration, which defines the destination bucket and optional name prefix for the current
+ * bucket's logs.
+ */
+@AutoValue
+public abstract class ProjectTeam {
+
+ public enum Team {
+ OWNERS, EDITORS, VIEWERS;
+
+ public String value() {
+ return name().toLowerCase();
+ }
+
+ @Override
+ public String toString() {
+ return value();
+ }
+
+ public static Team fromValue(String team) {
+ return valueOf(team.toUpperCase());
+ }
+ }
+
+ public abstract String projectNumber();
+
+ public abstract Team team();
+
+ @SerializedNames({ "projectNumber", "team" })
+ public static ProjectTeam create(String projectNumber, Team team) {
+ return new AutoValue_ProjectTeam(projectNumber, team);
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b8670b16/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/Resource.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/Resource.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/Resource.java
deleted file mode 100644
index 89ef315..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/Resource.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecloudstorage.domain;
-
-import static com.google.common.base.Objects.ToStringHelper;
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.Objects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.beans.ConstructorProperties;
-import java.net.URI;
-
-import org.jclouds.javax.annotation.Nullable;
-
-import com.google.common.base.CaseFormat;
-import com.google.common.base.Joiner;
-import com.google.common.base.Objects;
-import com.google.common.base.Splitter;
-import com.google.common.collect.Iterables;
-
-/**
- * Base class for Google Cloud Storage resources.
- */
-
-public class Resource {
-
- public enum Kind {
- BUCKET_ACCESS_CONTROL, BUCKET_ACCESS_CONTROLS,
- BUCKET, BUCKETS,
- OBJECT_ACCESS_CONTROL, OBJECT_ACCESS_CONTROLS,
- OBJECT, OBJECTS,
- COMPOSE_REQUEST;
-
- public String value() {
- return Joiner.on("#").join("storage", CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()));
- }
-
- @Override
- public String toString() {
- return value();
- }
-
- public static Kind fromValue(String kind) {
- return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE,
- Iterables.getLast(Splitter.on("#").split(checkNotNull(kind, "kind")))));
- }
- }
-
- protected final Kind kind;
- protected final String id;
- protected final URI selfLink;
- protected final String etag;
-
- @ConstructorProperties({ "kind", "id", "selfLink", "etag" })
- protected Resource(Kind kind, @Nullable String id, @Nullable URI selfLink, @Nullable String etag) {
- this.kind = checkNotNull(kind, "kind");
- this.id = id;
- this.selfLink = selfLink;
- this.etag = etag;
- }
-
- public Kind getKind() {
- return kind;
- }
-
- public String getId() {
- return id;
- }
-
- public URI getSelfLink() {
- return selfLink;
- }
-
- public String getEtag() {
- return etag;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(kind, id, selfLink, etag);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null || getClass() != obj.getClass())
- return false;
- Resource that = Resource.class.cast(obj);
- return equal(this.kind, that.kind) && equal(this.id, that.id);
- }
-
- protected ToStringHelper string() {
- return toStringHelper(this).omitNullValues().add("kind", kind).add("id", id).add("selfLink", selfLink)
- .add("etag", etag);
- }
-
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder<?> builder() {
- return new ConcreteBuilder();
- }
-
- public Builder<?> toBuilder() {
- return new ConcreteBuilder().fromResource(this);
- }
-
- public abstract static class Builder<T extends Builder<T>> {
-
- protected abstract T self();
-
- protected Kind kind;
- protected String id;
- protected URI selfLink;
- protected String etag;
-
- protected T kind(Kind kind) {
- this.kind = kind;
- return self();
- }
-
- public T id(String id) {
- this.id = id;
- return self();
- }
-
- public T selfLink(URI selfLink) {
- this.selfLink = selfLink;
- return self();
- }
-
- public T etag(String etag) {
- this.etag = etag;
- return self();
- }
-
- public Resource build() {
- return new Resource(kind, id, selfLink, etag);
- }
-
- public T fromResource(Resource in) {
- return this.kind(in.getKind()).id(in.getId()).selfLink(in.getSelfLink()).etag(in.getEtag());
- }
- }
-
- private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
- @Override
- protected ConcreteBuilder self() {
- return this;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b8670b16/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ResumableUpload.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ResumableUpload.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ResumableUpload.java
index ebb80a1..556347a 100644
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ResumableUpload.java
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/ResumableUpload.java
@@ -16,118 +16,28 @@
*/
package org.jclouds.googlecloudstorage.domain;
-import static com.google.common.base.Objects.toStringHelper;
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
import org.jclouds.javax.annotation.Nullable;
-import com.google.common.base.Objects.ToStringHelper;
+import com.google.auto.value.AutoValue;
/**
* Represents results of resumable upload response.
*/
-public class ResumableUpload {
-
- protected final Integer statusCode;
- protected final String uploadId;
- protected final String contentLength;
- protected final Long rangeUpperValue;
- protected final Long rangeLowerValue;
-
- private ResumableUpload(Integer statusCode, @Nullable String uploadId, @Nullable String contentLength,
- @Nullable Long rangeLowerValue, @Nullable Long rangeUpperValue) {
- if (rangeLowerValue != null && rangeUpperValue != null) {
- checkArgument(rangeLowerValue < rangeUpperValue, "lower range must less than upper range, was: %s - %s",
- rangeLowerValue, rangeUpperValue);
- }
- this.statusCode = checkNotNull(statusCode, "statusCode");
- this.uploadId = uploadId;
- this.contentLength = contentLength;
- this.rangeUpperValue = rangeUpperValue;
- this.rangeLowerValue = rangeLowerValue;
- }
-
- public String getUploadId() {
- return uploadId;
- }
-
- public Integer getStatusCode() {
- return statusCode;
- }
-
- public String getContentLength() {
- return contentLength;
- }
-
- public Long getRangeUpperValue() {
- return rangeUpperValue;
- }
-
- public Long getRangeLowerValue() {
- return rangeLowerValue;
- }
-
- protected ToStringHelper string() {
- return toStringHelper(this).add("statusCode", statusCode).add("uploadId", uploadId)
- .add("contentLength", contentLength).add("rangeUpperValue", rangeUpperValue)
- .add("rangeLowerValue", rangeLowerValue);
- }
-
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public Builder toBuilder() {
- return new Builder().fromResumableUpload(this);
- }
-
- public static final class Builder {
-
- protected String uploadId;
- protected Integer statusCode;
- protected String contentLength;
- protected Long rangeUpperValue;
- protected Long rangeLowerValue;
-
- public Builder uploadId(String uploadId) {
- this.uploadId = uploadId;
- return this;
- }
-
- public Builder statusCode(Integer statusCode) {
- this.statusCode = statusCode;
- return this;
- }
+@AutoValue
+public abstract class ResumableUpload {
- public Builder contentLength(String contentLength) {
- this.contentLength = contentLength;
- return this;
- }
+ public abstract int statusCode();
- public Builder rangeUpperValue(Long rangeUpperValue) {
- this.rangeUpperValue = rangeUpperValue;
- return this;
- }
+ @Nullable public abstract String uploadId();
- public Builder rangeLowerValue(Long rangeLowerValue) {
- this.rangeLowerValue = rangeLowerValue;
- return this;
- }
+ @Nullable public abstract String contentLength();
- public ResumableUpload build() {
- return new ResumableUpload(statusCode, uploadId, contentLength, rangeLowerValue, rangeUpperValue);
- }
+ @Nullable public abstract Long rangeUpperValue();
- public Builder fromResumableUpload(ResumableUpload in) {
- return this.statusCode(in.getStatusCode()).uploadId(in.getUploadId()).contentLength(in.getContentLength())
- .rangeUpperValue(in.getRangeUpperValue()).rangeLowerValue(in.getRangeLowerValue());
- }
+ @Nullable public abstract Long rangeLowerValue();
+ public static ResumableUpload create(int statusCode, String uploadId, String contentLength, Long rangeLowerValue,
+ Long rangeUpperValue) {
+ return new AutoValue_ResumableUpload(statusCode, uploadId, contentLength, rangeLowerValue, rangeUpperValue);
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b8670b16/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Action.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Action.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Action.java
deleted file mode 100644
index 67431a3..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Action.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecloudstorage.domain.internal;
-
-import static com.google.common.base.Objects.toStringHelper;
-
-import com.google.common.base.Objects;
-
-/**
- * This is an Internal Object used in BucketLifeCycles/Rules.
- */
-
-public class Action {
- private final String type;
-
- private Action(String type) {
- this.type = type;
- }
-
- public String getType() {
- return type;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(type);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Action other = (Action) obj;
- if (type == null) {
- if (other.type != null)
- return false;
- } else if (!type.equals(other.type))
- return false;
- return true;
- }
-
- protected Objects.ToStringHelper string() {
- return toStringHelper(this).add("type", type);
- }
-
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private String type;
-
- public Builder type(String type) {
- this.type = type;
- return this;
- }
-
- public Action build() {
- return new Action(this.type);
- }
-
- public Builder fromAction(Action in) {
- return this.type(in.getType());
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b8670b16/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/BucketCors.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/BucketCors.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/BucketCors.java
deleted file mode 100644
index 0be95c6..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/BucketCors.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecloudstorage.domain.internal;
-
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.Objects.toStringHelper;
-
-import java.util.Set;
-
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableSet;
-
-/**
- * The bucket's Cross-Origin Resource Sharing (CORS) configuration.
- *
- * @see <a href= "https://developers.google.com/storage/docs/cross-origin" />
- */
-
-public class BucketCors {
- private final Set<String> origin;
- private final Set<String> method;
- private final Set<String> responseHeader;
- private final Integer maxAgeSeconds;
-
- private BucketCors(Set<String> origin, Set<String> method, Set<String> responseHeader,
- Integer maxAgeSeconds) {
- this.origin = origin.isEmpty() ? null : origin;
- this.method = method.isEmpty() ? null : method;
- this.responseHeader = responseHeader.isEmpty() ? null : responseHeader;
- this.maxAgeSeconds = maxAgeSeconds;
- }
-
- public Set<String> getOrigin() {
- return origin;
- }
-
- public Set<String> getMethod() {
- return method;
- }
-
- public Set<String> getResponseHeader() {
- return responseHeader;
- }
-
- public Integer getMaxAgeSeconds() {
- return maxAgeSeconds;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(origin, method, responseHeader, maxAgeSeconds);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null || getClass() != obj.getClass())
- return false;
- BucketCors that = BucketCors.class.cast(obj);
- return equal(this.origin, that.origin) && equal(this.method, that.method)
- && equal(this.responseHeader, that.responseHeader) && equal(this.maxAgeSeconds, that.maxAgeSeconds);
- }
-
- protected Objects.ToStringHelper string() {
- return toStringHelper(this).omitNullValues().add("origin", origin).add("method", method).add("responseHeader", responseHeader)
- .add("maxAgeSeconds", maxAgeSeconds);
- }
-
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
-
- private ImmutableSet.Builder<String> origin = ImmutableSet.builder();
- private ImmutableSet.Builder<String> method = ImmutableSet.builder();
- private ImmutableSet.Builder<String> reponseHeader = ImmutableSet.builder();
- private Integer maxAgeSeconds;
-
- public Builder addOrigin(String origin) {
- this.origin.add(origin);
- return this;
- }
-
- public Builder origin(Set<String> origin) {
- this.origin.addAll(origin);
- return this;
- }
-
- public Builder addMethod(String method) {
- this.method.add(method);
- return this;
- }
-
- public Builder method(Set<String> method) {
- this.method.addAll(method);
- return this;
- }
-
- public Builder addResponseHeader(String responseHeader) {
- this.reponseHeader.add(responseHeader);
- return this;
- }
-
- public Builder responseHeaders(Set<String> responseHeaders) {
- this.reponseHeader.addAll(responseHeaders);
- return this;
- }
-
- public Builder maxAgeSeconds(Integer maxAgeSeconds) {
- this.maxAgeSeconds = maxAgeSeconds;
- return this;
- }
-
- public BucketCors build() {
- return new BucketCors(this.origin.build(), this.method.build(), this.reponseHeader.build(),
- this.maxAgeSeconds);
- }
-
- public Builder fromCors(BucketCors in) {
- return this.maxAgeSeconds(in.getMaxAgeSeconds()).origin(in.getOrigin()).method(in.getMethod())
- .responseHeaders(in.getResponseHeader());
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b8670b16/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/BucketLifeCycle.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/BucketLifeCycle.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/BucketLifeCycle.java
deleted file mode 100644
index 07a7461..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/BucketLifeCycle.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecloudstorage.domain.internal;
-
-import static com.google.common.base.Objects.toStringHelper;
-
-import java.util.Set;
-
-import com.google.common.base.Objects;
-import com.google.common.collect.ImmutableSet;
-
-/**
- * The bucket's lifecycle configuration.
- *
- * @see <a href= "https://developers.google.com/storage/docs/lifecycle" />
- */
-
-public class BucketLifeCycle {
-
- private final Set<Rule> rules;
-
- private BucketLifeCycle(Set<Rule> rules) {
- this.rules = rules.isEmpty() ? null : rules;
- }
-
- public Set<Rule> getRules() {
- return rules;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(rules);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- BucketLifeCycle other = (BucketLifeCycle) obj;
- if (rules == null) {
- if (other.rules != null)
- return false;
- } else if (!rules.equals(other.rules))
- return false;
- return true;
- }
-
- protected Objects.ToStringHelper string() {
- return toStringHelper(this).add("rule", rules);
- }
-
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
-
- ImmutableSet.Builder<Rule> rules = ImmutableSet.builder();
-
- public Builder addRule(Rule rule) {
- this.rules.add(rule);
- return this;
- }
-
- public Builder rule(Set<Rule> rules) {
- this.rules.addAll(rules);
- return this;
- }
-
- public BucketLifeCycle build() {
- return new BucketLifeCycle(this.rules.build());
- }
-
- public Builder fromLifeCycle(BucketLifeCycle in) {
- return this.rule(in.getRules());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b8670b16/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Condition.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Condition.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Condition.java
deleted file mode 100644
index d298fe7..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Condition.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecloudstorage.domain.internal;
-
-import static com.google.common.base.Objects.toStringHelper;
-
-import java.util.Date;
-
-import org.jclouds.javax.annotation.Nullable;
-
-import com.google.common.base.Objects;
-
-/**
- * This is an Internal Object used in BucketLifeCycles/Rules.
- */
-
-public class Condition {
- private final Integer age;
- private final Date createdBefore;
- private final Boolean isLive;
- private final Integer numNewerVersions;
-
- private Condition(@Nullable Integer age, @Nullable Date createdBefore, @Nullable Boolean isLive,
- @Nullable Integer numNewerVersions) {
- this.age = age;
- this.createdBefore = createdBefore;
- this.isLive = isLive;
- this.numNewerVersions = numNewerVersions;
- }
-
- public Integer getAge() {
- return age;
- }
-
- public Date getCreatedBefore() {
- return createdBefore;
- }
-
- public Boolean getIsLive() {
- return isLive;
- }
-
- public Integer getNumNewerVersions() {
- return numNewerVersions;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(age, createdBefore, isLive, numNewerVersions);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Condition other = (Condition) obj;
- if (age == null) {
- if (other.age != null)
- return false;
- } else if (!age.equals(other.age))
- return false;
- if (createdBefore == null) {
- if (other.createdBefore != null)
- return false;
- } else if (!createdBefore.equals(other.createdBefore))
- return false;
- if (isLive == null) {
- if (other.isLive != null)
- return false;
- } else if (!isLive.equals(other.isLive))
- return false;
- if (numNewerVersions == null) {
- if (other.numNewerVersions != null)
- return false;
- } else if (!numNewerVersions.equals(other.numNewerVersions))
- return false;
- return true;
- }
-
- protected Objects.ToStringHelper string() {
- return toStringHelper(this).add("age", age).add("createdBefore", createdBefore).add("isLive", isLive)
- .add("numNewerVersions", numNewerVersions);
- }
-
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static final class Builder {
-
- private Integer age;
- private Date createdBefore;
- private Boolean isLive;
- private Integer numNewerVersions;
-
- public Builder age(Integer age) {
- this.age = age;
- return this;
- }
-
- public Builder createdBefore(Date createdBefore) {
- this.createdBefore = createdBefore;
- return this;
- }
-
- public Builder isLive(Boolean isLive) {
- this.isLive = isLive;
- return this;
- }
-
- public Builder numNewerVersions(Integer numNewerVersions) {
- this.numNewerVersions = numNewerVersions;
- return this;
- }
-
- public Condition build() {
- return new Condition(this.age, this.createdBefore, this.isLive, this.numNewerVersions);
- }
-
- public Builder fromCondition(Condition in) {
- return this.age(in.getAge()).createdBefore(in.getCreatedBefore()).isLive(in.getIsLive())
- .numNewerVersions(in.getNumNewerVersions());
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b8670b16/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Logging.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Logging.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Logging.java
deleted file mode 100644
index 1bda912..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Logging.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecloudstorage.domain.internal;
-
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.Objects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.google.common.base.Objects;
-
-/**
- * The bucket's logging configuration, which defines the destination bucket and optional name prefix for the current
- * bucket's logs.
- *
- * @see <a href= "https://developers.google.com/storage/docs/accesslogs" />
- */
-
-public class Logging {
- private final String logBucket;
- private final String logObjectPrefix;
-
- private Logging(String logBucket, String logObjectPrefix) {
-
- this.logBucket = checkNotNull(logBucket, "logBucket");
- this.logObjectPrefix = checkNotNull(logObjectPrefix , "logObjectPrefix");
- }
-
- public String getLogBucket() {
- return logBucket;
- }
-
- public String getLogObjectPrefix() {
- return logObjectPrefix;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(logBucket, logObjectPrefix);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null || getClass() != obj.getClass())
- return false;
- Logging that = Logging.class.cast(obj);
- return equal(this.logBucket, that.logBucket) && equal(this.logObjectPrefix, that.logObjectPrefix);
- }
-
- protected Objects.ToStringHelper string() {
- return toStringHelper(this).add("logBucket", logBucket).add("logObjectPrefix", logObjectPrefix);
- }
-
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private String logBucket;
- private String logObjectPrefix;
-
- public Builder logBucket(String logBucket) {
- this.logBucket = logBucket;
- return this;
- }
-
- public Builder logObjectPrefix(String logObjectPrefix) {
- this.logObjectPrefix = logObjectPrefix;
- return this;
- }
-
- public Logging build() {
- return new Logging(this.logBucket, this.logObjectPrefix);
- }
-
- public Builder fromLogging(Logging in) {
- return this.logBucket(in.getLogBucket()).logObjectPrefix(in.getLogObjectPrefix());
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b8670b16/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Owner.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Owner.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Owner.java
deleted file mode 100644
index 6f9cbdf..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Owner.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecloudstorage.domain.internal;
-
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.Objects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.javax.annotation.Nullable;
-
-import com.google.common.base.Objects;
-
-/**
- * This is an internal object used in both Bucket and Object representation
- */
-
-public class Owner {
- private final String entity;
- private final String entityId;
-
- private Owner(String entity, @Nullable String entityId) {
- this.entity = checkNotNull(entity, "entity");
- this.entityId = entityId;
- }
-
- public String getEntity() {
- return entity;
- }
-
- public String getEntityId() {
- return entityId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(entity, entityId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null || getClass() != obj.getClass())
- return false;
- Owner that = Owner.class.cast(obj);
- return equal(this.entity, that.entity);
- }
-
- protected Objects.ToStringHelper string() {
- return toStringHelper(this).omitNullValues().add("entity", entity).add("entityId", entityId);
- }
-
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private String entity;
- private String entityId;
-
- public Builder entity(String entity) {
- this.entity = entity;
- return this;
- }
-
- public Builder entityId(String entityId) {
- this.entityId = entityId;
- return this;
- }
-
- public Owner build() {
- return new Owner(this.entity, this.entityId);
- }
-
- public Builder fromOwner(Owner in) {
- return this.entity(in.getEntity()).entityId(in.getEntityId());
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b8670b16/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/ProjectTeam.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/ProjectTeam.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/ProjectTeam.java
deleted file mode 100644
index f4bda2c..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/ProjectTeam.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecloudstorage.domain.internal;
-
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.Objects.toStringHelper;
-
-import com.google.common.base.Objects;
-
-/**
- * The bucket's logging configuration, which defines the destination bucket and optional name prefix for the current
- * bucket's logs.
- */
-
-public final class ProjectTeam {
-
- public enum Team {
- OWNERS, EDITORS, VIEWERS;
-
- public String value() {
- return name().toLowerCase();
- }
-
- @Override
- public String toString() {
- return value();
- }
-
- public static Team fromValue(String team) {
- return valueOf(team.toUpperCase());
- }
- }
-
- private final String projectNumber;
- private final Team team;
-
-
- private ProjectTeam(String projectNumber, Team team) {
- this.projectNumber = projectNumber;
- this.team = team;
- }
-
- public String getProjectNumber() {
- return projectNumber;
- }
-
- public Team getTeam() {
- return team;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(projectNumber, team);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null || getClass() != obj.getClass())
- return false;
- ProjectTeam that = ProjectTeam.class.cast(obj);
- return equal(this.projectNumber, that.projectNumber) && equal(this.team, that.team);
- }
-
- protected Objects.ToStringHelper string() {
- return toStringHelper(this).add("projectNumber", projectNumber).add("team", team);
- }
-
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
-
- private String projectNumber;
- private Team team;
-
- public Builder projectNumber(String projectNumber) {
- this.projectNumber = projectNumber;
- return this;
- }
-
- public Builder team(Team team) {
- this.team = team;
- return this;
- }
-
- public ProjectTeam build() {
- return new ProjectTeam(this.projectNumber, this.team);
- }
-
- public Builder fromProjectTeam(ProjectTeam in) {
- return this.projectNumber(in.getProjectNumber()).team(in.getTeam());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b8670b16/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Rule.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Rule.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Rule.java
deleted file mode 100644
index 45d298e..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Rule.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecloudstorage.domain.internal;
-
-import static com.google.common.base.Objects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.google.common.base.Objects;
-
-/**
- * The bucket's logging configuration, which defines the destination bucket and optional name prefix for the current
- * bucket's logs.
- */
-
-public class Rule {
- private final Action action;
- private final Condition condition;
-
- private Rule(Action action, Condition condition) {
- this.action = checkNotNull(action, "action");
- this.condition = checkNotNull(condition, "condition");
- }
-
- public Action getAction() {
- return action;
- }
-
- public Condition getCondition() {
- return condition;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(action, condition);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Rule other = (Rule) obj;
- if (action == null) {
- if (other.action != null)
- return false;
- } else if (!action.equals(other.action))
- return false;
- if (condition == null) {
- if (other.condition != null)
- return false;
- } else if (!condition.equals(other.condition))
- return false;
- return true;
- }
-
- protected Objects.ToStringHelper string() {
- return toStringHelper(this).add("condition", condition).add("action", action);
- }
-
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private Action action;
- private Condition condition;
-
- public Builder action(Action action) {
- this.action = action;
- return this;
- }
-
- public Builder condtion(Condition condition) {
- this.condition = condition;
- return this;
- }
-
- public Rule build() {
- return new Rule(this.action, this.condition);
- }
-
- public Builder fromRule(Rule in) {
- return this.action(in.getAction()).condtion(in.getCondition());
-
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b8670b16/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Versioning.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Versioning.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Versioning.java
deleted file mode 100644
index dd42113..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Versioning.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecloudstorage.domain.internal;
-
-import static com.google.common.base.Objects.toStringHelper;
-
-import com.google.common.base.Objects;
-
-/**
- * The bucket's versioning configuration.
- *
- * @see <a href= "https://developers.google.com/storage/docs/object-versioning" />
- */
-
-public final class Versioning {
- private final Boolean enabled;
-
- private Versioning(Boolean enabled) {
- this.enabled = enabled;
- }
-
- public Boolean isEnabled() {
- return enabled;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(enabled);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Versioning other = (Versioning) obj;
- if (enabled == null) {
- if (other.enabled != null)
- return false;
- } else if (!enabled.equals(other.enabled))
- return false;
- return true;
- }
-
- protected Objects.ToStringHelper string() {
- return toStringHelper(this).add("enabled", enabled);
- }
-
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
-
- private Boolean enabled;
-
- public Builder enalbled(Boolean enabled) {
- this.enabled = enabled;
- return this;
- }
-
- public Versioning build() {
- return new Versioning(this.enabled);
- }
-
- public Builder fromVersioning(Versioning in) {
- return this.enalbled(in.isEnabled());
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b8670b16/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Website.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Website.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Website.java
deleted file mode 100644
index 7218c85..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/internal/Website.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecloudstorage.domain.internal;
-
-import static com.google.common.base.Objects.equal;
-import static com.google.common.base.Objects.toStringHelper;
-
-import org.jclouds.javax.annotation.Nullable;
-
-import com.google.common.base.Objects;
-
-/**
- * This is a internal object in bucket resource
- *
- * @see <a href= "https://developers.google.com/storage/docs/website-configuration" />
- */
-
-public class Website {
- private final String mainPageSuffix;
- private final String notFoundPage;
-
- private Website(@Nullable String mainPageSuffix, @Nullable String notFoundPage) {
-
- this.mainPageSuffix = mainPageSuffix;
- this.notFoundPage = notFoundPage;
- }
-
- public String getMainPageSuffix() {
- return mainPageSuffix;
- }
-
- public String getNotFoundPage() {
- return notFoundPage;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(mainPageSuffix, notFoundPage);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null || getClass() != obj.getClass())
- return false;
- Website that = Website.class.cast(obj);
- return equal(this.mainPageSuffix, that.mainPageSuffix);
- }
-
- protected Objects.ToStringHelper string() {
- return toStringHelper(this).add("mainPageSuffix", mainPageSuffix).add("notFoundPage", notFoundPage);
- }
-
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static class Builder {
- private String mainPageSuffix;
- private String notFoundPage;
-
- public Builder mainPageSuffix(String mainPageSuffix) {
- this.mainPageSuffix = mainPageSuffix;
- return this;
- }
-
- public Builder notFoundPage(String notFoundPage) {
- this.notFoundPage = notFoundPage;
- return this;
- }
-
- public Website build() {
- return new Website(this.mainPageSuffix, this.notFoundPage);
- }
-
- public Builder fromWebsite(Website in) {
- return this.mainPageSuffix(in.getMainPageSuffix()).notFoundPage(in.getNotFoundPage());
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b8670b16/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/BucketAccessControlsTemplate.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/BucketAccessControlsTemplate.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/BucketAccessControlsTemplate.java
index 3d62b76..04221aa 100644
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/BucketAccessControlsTemplate.java
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/BucketAccessControlsTemplate.java
@@ -16,50 +16,18 @@
*/
package org.jclouds.googlecloudstorage.domain.templates;
-import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Role;
+import org.jclouds.googlecloudstorage.domain.BucketAccessControls.Role;
-/**
- * Represents a Object Access Control Resource.
- *
- * @see <a href= "https://developers.google.com/storage/docs/json_api/v1/objectAccessControls"/>
- */
-public class BucketAccessControlsTemplate {
-
- protected String entity;
- protected Role role;
-
- public BucketAccessControlsTemplate role(Role role) {
- this.role = role;
- return this;
- }
-
- public BucketAccessControlsTemplate entity(String entity) {
- this.entity = entity;
- return this;
- }
+import com.google.auto.value.AutoValue;
- public String getEntity() {
- return entity;
- }
-
- public Role getRole() {
- return role;
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static BucketAccessControlsTemplate fromObjectAccessControlsTemplate(
- BucketAccessControlsTemplate objectAccessControlsTemplate) {
- return Builder.fromObjectAccessControlsTemplate(objectAccessControlsTemplate);
- }
+@AutoValue
+public abstract class BucketAccessControlsTemplate {
- public static class Builder {
+ public abstract String entity();
- public static BucketAccessControlsTemplate fromObjectAccessControlsTemplate(BucketAccessControlsTemplate in) {
- return new BucketAccessControlsTemplate().role(in.getRole()).entity(in.getEntity());
- }
+ public abstract Role role();
+ public static BucketAccessControlsTemplate create(String entity, Role role) {
+ return new AutoValue_BucketAccessControlsTemplate(entity, role);
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b8670b16/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/BucketTemplate.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/BucketTemplate.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/BucketTemplate.java
index 5e85bd0..7434757 100644
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/BucketTemplate.java
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/BucketTemplate.java
@@ -17,35 +17,35 @@
package org.jclouds.googlecloudstorage.domain.templates;
-import java.util.Set;
+import java.util.List;
+import org.jclouds.googlecloudstorage.domain.Bucket.Cors;
+import org.jclouds.googlecloudstorage.domain.Bucket.LifeCycle;
+import org.jclouds.googlecloudstorage.domain.Bucket.Logging;
+import org.jclouds.googlecloudstorage.domain.Bucket.Versioning;
+import org.jclouds.googlecloudstorage.domain.Bucket.Website;
import org.jclouds.googlecloudstorage.domain.BucketAccessControls;
-import org.jclouds.googlecloudstorage.domain.DefaultObjectAccessControls;
import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Location;
import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.StorageClass;
-import org.jclouds.googlecloudstorage.domain.internal.BucketCors;
-import org.jclouds.googlecloudstorage.domain.internal.BucketLifeCycle;
-import org.jclouds.googlecloudstorage.domain.internal.Logging;
-import org.jclouds.googlecloudstorage.domain.internal.Owner;
-import org.jclouds.googlecloudstorage.domain.internal.Versioning;
-import org.jclouds.googlecloudstorage.domain.internal.Website;
+import org.jclouds.googlecloudstorage.domain.ObjectAccessControls;
+import org.jclouds.googlecloudstorage.domain.Owner;
-import com.google.common.collect.Sets;
+import com.google.common.collect.Lists;
public class BucketTemplate {
- protected String name;
- protected Long projectNumber;
- protected Set<BucketAccessControls> acl = Sets.newLinkedHashSet();
- protected Set<DefaultObjectAccessControls> defaultObjectAccessControls = Sets.newLinkedHashSet();
- protected Owner owner;
- protected Location location;
- protected Website website;
- protected Logging logging;
- protected Versioning versioning;
- protected Set<BucketCors> cors = Sets.newLinkedHashSet();
- protected BucketLifeCycle lifeCycle;
- protected StorageClass storageClass;
+ private String name;
+ private Long projectNumber;
+ private List<BucketAccessControls> acl = Lists.newArrayList();
+ private List<ObjectAccessControls> defaultObjectAccessControls = Lists.newArrayList();
+ private Owner owner;
+ private Location location;
+ private Website website;
+ private Logging logging;
+ private Versioning versioning;
+ private List<Cors> cors = Lists.newArrayList();
+ private LifeCycle lifeCycle;
+ private StorageClass storageClass;
public BucketTemplate name(String name) {
this.name = name;
@@ -82,7 +82,7 @@ public class BucketTemplate {
return this;
}
- public BucketTemplate lifeCycle(BucketLifeCycle lifeCycle) {
+ public BucketTemplate lifeCycle(LifeCycle lifeCycle) {
this.lifeCycle = lifeCycle;
return this;
}
@@ -97,97 +97,76 @@ public class BucketTemplate {
return this;
}
- public BucketTemplate acl(Set<BucketAccessControls> acl) {
-
+ public BucketTemplate acl(List<BucketAccessControls> acl) {
this.acl.addAll(acl);
return this;
}
- public BucketTemplate addDefaultObjectAccessControls(DefaultObjectAccessControls oac) {
+ public BucketTemplate addDefaultObjectAccessControls(ObjectAccessControls oac) {
this.defaultObjectAccessControls.add(oac);
return this;
}
- public BucketTemplate defaultObjectAccessControls(Set<DefaultObjectAccessControls> defaultObjectAcl) {
+ public BucketTemplate defaultObjectAccessControls(List<ObjectAccessControls> defaultObjectAcl) {
this.defaultObjectAccessControls.addAll(defaultObjectAcl);
return this;
}
- public BucketTemplate addCORS(BucketCors cors) {
+ public BucketTemplate addCORS(Cors cors) {
this.cors.add(cors);
return this;
}
- public BucketTemplate cors(Set<BucketCors> cors) {
+ public BucketTemplate cors(List<Cors> cors) {
this.cors.addAll(cors);
return this;
}
- public Long getProjectNumber() {
+ public Long projectNumber() {
return projectNumber;
}
- public String getName() {
+ public String name() {
return name;
}
- public Set<BucketAccessControls> getAcl() {
+ public List<BucketAccessControls> acl() {
return acl;
}
- public Set<DefaultObjectAccessControls> getDefaultObjectAccessControls() {
+ public List<ObjectAccessControls> defaultObjectAccessControls() {
return defaultObjectAccessControls;
}
- public Owner getOwner() {
+ public Owner owner() {
return owner;
}
- public Location getLocation() {
+ public Location location() {
return location;
}
- public Website getWebsite() {
+ public Website website() {
return website;
}
- public Logging getLogging() {
+ public Logging logging() {
return logging;
}
- public Versioning getVersioning() {
+ public Versioning versioning() {
return versioning;
}
- public Set<BucketCors> getCors() {
+ public List<Cors> cors() {
return cors;
}
- public BucketLifeCycle getLifeCycle() {
+ public LifeCycle lifeCycle() {
return lifeCycle;
}
- public StorageClass getStorageClass() {
+ public StorageClass storageClass() {
return storageClass;
}
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static BucketTemplate fromBucketsTemplate(BucketTemplate bucketTemplate) {
- return Builder.fromBucketsTemplate(bucketTemplate);
- }
-
- public static class Builder {
-
- public static BucketTemplate fromBucketsTemplate(BucketTemplate in) {
- return new BucketTemplate().name(in.getName()).projectNumber(in.getProjectNumber()).acl(in.getAcl())
- .defaultObjectAccessControls(in.getDefaultObjectAccessControls()).owner(in.getOwner())
- .location(in.getLocation()).website(in.getWebsite()).logging(in.getLogging())
- .versioning(in.getVersioning()).cors(in.getCors()).lifeCycle(in.getLifeCycle())
- .storageClass(in.getStorageClass());
- }
-
- }
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b8670b16/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ComposeObjectTemplate.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ComposeObjectTemplate.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ComposeObjectTemplate.java
index 48372cc..0af32ea 100644
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ComposeObjectTemplate.java
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ComposeObjectTemplate.java
@@ -17,63 +17,22 @@
package org.jclouds.googlecloudstorage.domain.templates;
-import java.util.Set;
+import java.util.List;
import org.jclouds.googlecloudstorage.domain.GCSObject;
-import org.jclouds.googlecloudstorage.domain.Resource.Kind;
-import com.google.common.collect.Sets;
+import com.google.auto.value.AutoValue;
-public class ComposeObjectTemplate {
+@AutoValue
+public abstract class ComposeObjectTemplate {
- protected Kind kind;
- protected ObjectTemplate destination;
- protected Set<GCSObject> sourceObjects = Sets.newLinkedHashSet();
+ private final String kind = "storage/composeRequest";
- public ComposeObjectTemplate() {
- this.kind = Kind.COMPOSE_REQUEST;
- }
-
- public ComposeObjectTemplate destination(ObjectTemplate destination) {
- this.destination = destination;
- return this;
- }
-
- public ComposeObjectTemplate addsourceObject(GCSObject sourceObject) {
- this.sourceObjects.add(sourceObject);
- return this;
- }
-
- public ComposeObjectTemplate sourceObjects(Set<GCSObject> sourceObjects) {
- this.sourceObjects.addAll(sourceObjects);
- return this;
- }
-
- public Kind getKind() {
- return kind;
- }
-
- public ObjectTemplate getDestination() {
- return destination;
- }
-
- public Set<GCSObject> getSourceObjects() {
- return sourceObjects;
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static ComposeObjectTemplate fromComposeObjectTemplate(ComposeObjectTemplate composeTemplate) {
- return Builder.fromComposeObjectTemplate(composeTemplate);
- }
-
- public static class Builder {
+ public abstract List<GCSObject> sourceObjects();
- public static ComposeObjectTemplate fromComposeObjectTemplate(ComposeObjectTemplate in) {
- return new ComposeObjectTemplate().sourceObjects(in.getSourceObjects()).destination(in.getDestination());
+ public abstract ObjectTemplate destination();
- }
+ public static ComposeObjectTemplate create(List<GCSObject> sourceObjects, ObjectTemplate destination) {
+ return new AutoValue_ComposeObjectTemplate(sourceObjects, destination);
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b8670b16/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/DefaultObjectAccessControlsTemplate.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/DefaultObjectAccessControlsTemplate.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/DefaultObjectAccessControlsTemplate.java
deleted file mode 100644
index 48648ad..0000000
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/DefaultObjectAccessControlsTemplate.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.googlecloudstorage.domain.templates;
-
-import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.ObjectRole;
-
-/**
- * Represents a Object Access Control Resource
- *
- * @see <a href= "https://developers.google.com/storage/docs/json_api/v1/objectAccessControls"/>
- */
-public class DefaultObjectAccessControlsTemplate {
-
- private String entity;
- private ObjectRole role;
-
- public DefaultObjectAccessControlsTemplate role(ObjectRole role) {
- this.role = role;
- return this;
- }
-
- public DefaultObjectAccessControlsTemplate entity(String entity) {
- this.entity = entity;
- return this;
- }
-
- public String getEntity() {
- return entity;
- }
-
- public ObjectRole getRole() {
- return role;
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static DefaultObjectAccessControlsTemplate fromObjectAccessControlsTemplate(
- DefaultObjectAccessControlsTemplate objectAccessControlsTemplate) {
- return Builder.fromObjectAccessControlsTemplate(objectAccessControlsTemplate);
- }
-
- public static class Builder {
-
- public static DefaultObjectAccessControlsTemplate fromObjectAccessControlsTemplate(
- DefaultObjectAccessControlsTemplate in) {
- return new DefaultObjectAccessControlsTemplate().role(in.getRole()).entity(in.getEntity());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b8670b16/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ObjectAccessControlsTemplate.java
----------------------------------------------------------------------
diff --git a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ObjectAccessControlsTemplate.java b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ObjectAccessControlsTemplate.java
index a3f45ed..a8e1afb 100644
--- a/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ObjectAccessControlsTemplate.java
+++ b/google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ObjectAccessControlsTemplate.java
@@ -18,48 +18,16 @@ package org.jclouds.googlecloudstorage.domain.templates;
import org.jclouds.googlecloudstorage.domain.DomainResourceReferences.ObjectRole;
-/**
- * Represents a Object Access Control Resource.
- *
- * @see <a href= "https://developers.google.com/storage/docs/json_api/v1/objectAccessControls"/>
- */
-public class ObjectAccessControlsTemplate {
-
- protected String entity;
- protected ObjectRole role;
-
- public ObjectAccessControlsTemplate role(ObjectRole role) {
- this.role = role;
- return this;
- }
-
- public ObjectAccessControlsTemplate entity(String entity) {
- this.entity = entity;
- return this;
- }
+import com.google.auto.value.AutoValue;
- public String getEntity() {
- return entity;
- }
-
- public ObjectRole getRole() {
- return role;
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static ObjectAccessControlsTemplate fromObjectAccessControlsTemplate(
- ObjectAccessControlsTemplate objectAccessControlsTemplate) {
- return Builder.fromObjectAccessControlsTemplate(objectAccessControlsTemplate);
- }
+@AutoValue
+public abstract class ObjectAccessControlsTemplate {
- public static class Builder {
+ public abstract String entity();
- public static ObjectAccessControlsTemplate fromObjectAccessControlsTemplate(ObjectAccessControlsTemplate in) {
- return new ObjectAccessControlsTemplate().role(in.getRole()).entity(in.getEntity());
- }
+ public abstract ObjectRole role();
+ public static ObjectAccessControlsTemplate create(String entity, ObjectRole role) {
+ return new AutoValue_ObjectAccessControlsTemplate(entity, role);
}
}