mirror of https://github.com/apache/jclouds.git
openstack: adjusting beans in openstack-quantum, openstack-glance and openstack-swift to use ConstructorProperties and Named annotations
This commit is contained in:
parent
294e405593
commit
908e164698
|
@ -108,21 +108,10 @@ public class Resource implements Comparable<Resource> {
|
||||||
@ConstructorProperties({
|
@ConstructorProperties({
|
||||||
"id", "name", "links"
|
"id", "name", "links"
|
||||||
})
|
})
|
||||||
protected Resource(String id, @Nullable String name, Set<Link> links) {
|
protected Resource(String id, @Nullable String name, @Nullable Set<Link> links) {
|
||||||
this.id = checkNotNull(id, "id");
|
this.id = checkNotNull(id, "id");
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.links = ImmutableSet.copyOf(checkNotNull(links, "links"));
|
this.links = links == null ? ImmutableSet.<Link>of() : ImmutableSet.copyOf(checkNotNull(links, "links"));
|
||||||
}
|
|
||||||
|
|
||||||
// leaving till beans in other openstack projects are updated
|
|
||||||
@Deprecated
|
|
||||||
protected Resource(Builder<?> builder) {
|
|
||||||
this(builder.id, builder.name, builder.links);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
protected Resource() {
|
|
||||||
id = null; name = null; links = ImmutableSet.of();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,11 +18,18 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.glance.v1_0.domain;
|
package org.jclouds.openstack.glance.v1_0.domain;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.openstack.v2_0.domain.Link;
|
||||||
import org.jclouds.openstack.v2_0.domain.Resource;
|
import org.jclouds.openstack.v2_0.domain.Resource;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An image the Glance server knows about
|
* An image the Glance server knows about
|
||||||
|
@ -32,6 +39,9 @@ import com.google.gson.annotations.SerializedName;
|
||||||
* @see <a href= "https://github.com/openstack/glance/blob/master/glance/api/v1/images.py" />
|
* @see <a href= "https://github.com/openstack/glance/blob/master/glance/api/v1/images.py" />
|
||||||
*/
|
*/
|
||||||
public class Image extends Resource {
|
public class Image extends Resource {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
public static enum Status {
|
public static enum Status {
|
||||||
|
|
||||||
UNRECOGNIZED, ACTIVE, SAVING, QUEUED, KILLED, PENDING_DELETE, DELETED;
|
UNRECOGNIZED, ACTIVE, SAVING, QUEUED, KILLED, PENDING_DELETE, DELETED;
|
||||||
|
@ -59,15 +69,15 @@ public class Image extends Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> extends Resource.Builder<T> {
|
public static abstract class Builder<T extends Builder<T>> extends Resource.Builder<T> {
|
||||||
private Optional<ContainerFormat> containerFormat = Optional.absent();
|
protected ContainerFormat containerFormat;
|
||||||
private Optional<DiskFormat> diskFormat = Optional.absent();
|
protected DiskFormat diskFormat;
|
||||||
private Optional<Long> size = Optional.absent();
|
protected Long size;
|
||||||
private Optional<String> checksum = Optional.absent();
|
protected String checksum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Image#getContainerFormat()
|
* @see Image#getContainerFormat()
|
||||||
*/
|
*/
|
||||||
public T containerFormat(Optional<ContainerFormat> containerFormat) {
|
public T containerFormat(ContainerFormat containerFormat) {
|
||||||
this.containerFormat = containerFormat;
|
this.containerFormat = containerFormat;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
@ -75,7 +85,7 @@ public class Image extends Resource {
|
||||||
/**
|
/**
|
||||||
* @see Image#getDiskFormat()
|
* @see Image#getDiskFormat()
|
||||||
*/
|
*/
|
||||||
public T diskFormat(Optional<DiskFormat> diskFormat) {
|
public T diskFormat(DiskFormat diskFormat) {
|
||||||
this.diskFormat = diskFormat;
|
this.diskFormat = diskFormat;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
@ -83,56 +93,30 @@ public class Image extends Resource {
|
||||||
/**
|
/**
|
||||||
* @see Image#getSize()
|
* @see Image#getSize()
|
||||||
*/
|
*/
|
||||||
public T size(Optional<Long> size) {
|
public T size(Long size) {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Image#getSize()
|
* @see Image#getChecksum()
|
||||||
*/
|
*/
|
||||||
public T checksum(Optional<String> checksum) {
|
public T checksum(String checksum) {
|
||||||
this.checksum = checksum;
|
this.checksum = checksum;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Image#getContainerFormat()
|
|
||||||
*/
|
|
||||||
public T containerFormat(ContainerFormat containerFormat) {
|
|
||||||
return containerFormat(Optional.of(containerFormat));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Image#getDiskFormat()
|
|
||||||
*/
|
|
||||||
public T diskFormat(DiskFormat diskFormat) {
|
|
||||||
return diskFormat(Optional.of(diskFormat));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Image#getSize()
|
|
||||||
*/
|
|
||||||
public T size(long size) {
|
|
||||||
return size(Optional.of(size));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Image#getSize()
|
|
||||||
*/
|
|
||||||
public T checksum(String checksum) {
|
|
||||||
return checksum(Optional.of(checksum));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Image build() {
|
public Image build() {
|
||||||
return new Image(this);
|
return new Image(id, name, links, containerFormat, diskFormat, size, checksum);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T fromImage(Image in) {
|
public T fromImage(Image in) {
|
||||||
return super.fromResource(in).containerFormat(in.getContainerFormat()).diskFormat(in.getDiskFormat()).size(
|
return super.fromResource(in)
|
||||||
in.getSize()).checksum(in.getChecksum());
|
.containerFormat(in.getContainerFormat().orNull())
|
||||||
|
.diskFormat(in.getDiskFormat().orNull())
|
||||||
|
.size(in.getSize().orNull())
|
||||||
|
.checksum(in.getChecksum().orNull());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||||
|
@ -142,29 +126,23 @@ public class Image extends Resource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Image() {
|
@Named("container_format")
|
||||||
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
|
private final Optional<ContainerFormat> containerFormat;
|
||||||
// prohibited in GAE. This also implies fields are not final.
|
@Named("disk_format")
|
||||||
// see http://code.google.com/p/jclouds/issues/detail?id=925
|
private final Optional<DiskFormat> diskFormat;
|
||||||
}
|
private final Optional<Long> size;
|
||||||
|
private final Optional<String> checksum;
|
||||||
|
|
||||||
// | container_format | varchar(20) | YES | | NULL | |
|
@ConstructorProperties({
|
||||||
@SerializedName("container_format")
|
"id", "name", "links", "container_format", "disk_format", "size", "checksum"
|
||||||
private Optional<ContainerFormat> containerFormat = Optional.absent();
|
})
|
||||||
// | disk_format | varchar(20) | YES | | NULL | |
|
protected Image(String id, @Nullable String name, Set<Link> links, @Nullable ContainerFormat containerFormat,
|
||||||
@SerializedName("disk_format")
|
@Nullable DiskFormat diskFormat, @Nullable Long size, @Nullable String checksum) {
|
||||||
private Optional<DiskFormat> diskFormat = Optional.absent();
|
super(id, name, links);
|
||||||
// | size | bigint(20) | YES | | NULL | |
|
this.containerFormat = Optional.fromNullable(containerFormat);
|
||||||
private Optional<Long> size = Optional.absent();
|
this.diskFormat = Optional.fromNullable(diskFormat);
|
||||||
// | checksum | varchar(32) | YES | | NULL | |
|
this.size = Optional.fromNullable(size);
|
||||||
private Optional<String> checksum = Optional.absent();
|
this.checksum = Optional.fromNullable(checksum);
|
||||||
|
|
||||||
protected Image(Builder<?> builder) {
|
|
||||||
super(builder);
|
|
||||||
this.containerFormat = builder.containerFormat;
|
|
||||||
this.diskFormat = builder.diskFormat;
|
|
||||||
this.size = builder.size;
|
|
||||||
this.checksum = builder.checksum;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<ContainerFormat> getContainerFormat() {
|
public Optional<ContainerFormat> getContainerFormat() {
|
||||||
|
@ -180,12 +158,28 @@ public class Image extends Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<String> getChecksum() {
|
public Optional<String> getChecksum() {
|
||||||
return checksum;
|
return this.checksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Objects.ToStringHelper string() {
|
public int hashCode() {
|
||||||
return super.string().add("containerFormat", containerFormat).add("diskFormat", diskFormat).add("size", size)
|
return Objects.hashCode(containerFormat, diskFormat, size, checksum);
|
||||||
.add("checksum", checksum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) return true;
|
||||||
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
|
Image that = Image.class.cast(obj);
|
||||||
|
return super.equals(that) && Objects.equal(this.containerFormat, that.containerFormat)
|
||||||
|
&& Objects.equal(this.diskFormat, that.diskFormat)
|
||||||
|
&& Objects.equal(this.size, that.size)
|
||||||
|
&& Objects.equal(this.checksum, that.checksum);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ToStringHelper string() {
|
||||||
|
return super.string()
|
||||||
|
.add("containerFormat", containerFormat).add("diskFormat", diskFormat).add("size", size).add("checksum", checksum);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,15 +20,20 @@ package org.jclouds.openstack.glance.v1_0.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import javax.inject.Named;
|
||||||
import com.google.common.base.Predicates;
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.openstack.v2_0.domain.Link;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detailed listing of an Image
|
* Detailed listing of an Image
|
||||||
|
@ -49,16 +54,16 @@ public class ImageDetails extends Image {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> extends Image.Builder<T> {
|
public static abstract class Builder<T extends Builder<T>> extends Image.Builder<T> {
|
||||||
private long minDisk;
|
protected long minDisk;
|
||||||
private long minRam;
|
protected long minRam;
|
||||||
private Optional<String> location = Optional.absent();
|
protected String location;
|
||||||
private Optional<String> owner = Optional.absent();
|
protected String owner;
|
||||||
private Date updatedAt;
|
protected Date updatedAt;
|
||||||
private Date createdAt;
|
protected Date createdAt;
|
||||||
private Optional<Date> deletedAt = Optional.absent();
|
protected Date deletedAt;
|
||||||
private Status status = Status.UNRECOGNIZED;
|
protected Image.Status status;
|
||||||
private boolean isPublic;
|
protected boolean isPublic;
|
||||||
private Map<String, String> properties = ImmutableMap.of();
|
protected Map<String, String> properties = ImmutableMap.of();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ImageDetails#getMinDisk()
|
* @see ImageDetails#getMinDisk()
|
||||||
|
@ -76,26 +81,11 @@ public class ImageDetails extends Image {
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ImageDetails#getLocation()
|
|
||||||
*/
|
|
||||||
public T location(Optional<String> location) {
|
|
||||||
this.location = location;
|
|
||||||
return self();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ImageDetails#getLocation()
|
* @see ImageDetails#getLocation()
|
||||||
*/
|
*/
|
||||||
public T location(String location) {
|
public T location(String location) {
|
||||||
return location(Optional.of(location));
|
this.location = location;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ImageDetails#getOwner()
|
|
||||||
*/
|
|
||||||
public T owner(Optional<String> owner) {
|
|
||||||
this.owner = owner;
|
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +93,8 @@ public class ImageDetails extends Image {
|
||||||
* @see ImageDetails#getOwner()
|
* @see ImageDetails#getOwner()
|
||||||
*/
|
*/
|
||||||
public T owner(String owner) {
|
public T owner(String owner) {
|
||||||
return owner(Optional.of(owner));
|
this.owner = owner;
|
||||||
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -125,22 +116,15 @@ public class ImageDetails extends Image {
|
||||||
/**
|
/**
|
||||||
* @see ImageDetails#getDeletedAt()
|
* @see ImageDetails#getDeletedAt()
|
||||||
*/
|
*/
|
||||||
public T deletedAt(Optional<Date> deletedAt) {
|
public T deletedAt(Date deletedAt) {
|
||||||
this.deletedAt = deletedAt;
|
this.deletedAt = deletedAt;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see ImageDetails#getDeletedAt()
|
|
||||||
*/
|
|
||||||
public T deletedAt(Date deletedAt) {
|
|
||||||
return deletedAt(Optional.of(deletedAt));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ImageDetails#getStatus()
|
* @see ImageDetails#getStatus()
|
||||||
*/
|
*/
|
||||||
public T status(Status status) {
|
public T status(Image.Status status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
@ -157,18 +141,26 @@ public class ImageDetails extends Image {
|
||||||
* @see ImageDetails#getProperties()
|
* @see ImageDetails#getProperties()
|
||||||
*/
|
*/
|
||||||
public T properties(Map<String, String> properties) {
|
public T properties(Map<String, String> properties) {
|
||||||
this.properties = properties;
|
this.properties = ImmutableMap.copyOf(checkNotNull(properties, "properties"));
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageDetails build() {
|
public ImageDetails build() {
|
||||||
return new ImageDetails(this);
|
return new ImageDetails(id, name, links, containerFormat, diskFormat, size, checksum, minDisk, minRam, location, owner, updatedAt, createdAt, deletedAt, status, isPublic, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T fromImageDetails(ImageDetails in) {
|
public T fromImageDetails(ImageDetails in) {
|
||||||
return super.fromImage(in).minDisk(in.getMinDisk()).minRam(in.getMinRam()).location(in.getLocation())
|
return super.fromImage(in)
|
||||||
.updatedAt(in.getUpdatedAt()).createdAt(in.getCreatedAt()).deletedAt(in.getDeletedAt()).status(
|
.minDisk(in.getMinDisk())
|
||||||
in.getStatus()).isPublic(in.isPublic()).properties(in.getProperties());
|
.minRam(in.getMinRam())
|
||||||
|
.location(in.getLocation().orNull())
|
||||||
|
.owner(in.getOwner().orNull())
|
||||||
|
.updatedAt(in.getUpdatedAt())
|
||||||
|
.createdAt(in.getCreatedAt())
|
||||||
|
.deletedAt(in.getDeletedAt().orNull())
|
||||||
|
.status(in.getStatus())
|
||||||
|
.isPublic(in.isPublic())
|
||||||
|
.properties(in.getProperties());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,49 +171,42 @@ public class ImageDetails extends Image {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ImageDetails() {
|
@Named("min_disk")
|
||||||
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
|
private final long minDisk;
|
||||||
// prohibited in GAE. This also implies fields are not final.
|
@Named("min_ram")
|
||||||
// see http://code.google.com/p/jclouds/issues/detail?id=925
|
private final long minRam;
|
||||||
}
|
private final Optional<String> location;
|
||||||
|
private final Optional<String> owner;
|
||||||
|
@Named("updated_at")
|
||||||
|
private final Date updatedAt;
|
||||||
|
@Named("created_at")
|
||||||
|
private final Date createdAt;
|
||||||
|
@Named("deleted_at")
|
||||||
|
private final Optional<Date> deletedAt;
|
||||||
|
private final Image.Status status;
|
||||||
|
@Named("is_public")
|
||||||
|
private final boolean isPublic;
|
||||||
|
private final Map<String, String> properties;
|
||||||
|
|
||||||
// | min_disk | int(11) | YES | | NULL | |
|
@ConstructorProperties({
|
||||||
@SerializedName("min_disk")
|
"id", "name", "links", "container_format", "disk_format", "size", "checksum", "min_disk", "min_ram", "location", "owner", "updated_at", "created_at", "deleted_at", "status", "is_public", "properties"
|
||||||
private long minDisk;
|
})
|
||||||
// | min_ram | int(11) | YES | | NULL | |
|
protected ImageDetails(String id, @Nullable String name, Set<Link> links, @Nullable ContainerFormat containerFormat,
|
||||||
@SerializedName("min_ram")
|
@Nullable DiskFormat diskFormat, @Nullable Long size, @Nullable String checksum, long minDisk,
|
||||||
private long minRam;
|
long minRam, @Nullable String location, @Nullable String owner, Date updatedAt,
|
||||||
// | location | text | YES | | NULL | |
|
Date createdAt, @Nullable Date deletedAt, Image.Status status, boolean isPublic,
|
||||||
private Optional<String> location = Optional.absent();
|
Map<String, String> properties) {
|
||||||
// | owner | varchar(255) | YES | | NULL | |
|
super(id, name, links, containerFormat, diskFormat, size, checksum);
|
||||||
private Optional<String> owner = Optional.absent();
|
this.minDisk = minDisk;
|
||||||
// | updated_at | datetime | YES | | NULL | |
|
this.minRam = minRam;
|
||||||
@SerializedName("updated_at")
|
this.location = Optional.fromNullable(location);
|
||||||
private Date updatedAt;
|
this.owner = Optional.fromNullable(owner);
|
||||||
// | created_at | datetime | NO | | NULL | |
|
this.updatedAt = checkNotNull(updatedAt, "updatedAt");
|
||||||
@SerializedName("created_at")
|
this.createdAt = checkNotNull(createdAt, "createdAt");
|
||||||
private Date createdAt;
|
this.deletedAt = Optional.fromNullable(deletedAt);
|
||||||
@SerializedName("deleted_at")
|
this.status = checkNotNull(status, "status");
|
||||||
private Optional<Date> deletedAt = Optional.absent();
|
this.isPublic = isPublic;
|
||||||
// | status | varchar(30) | NO | | NULL | |
|
this.properties = ImmutableMap.copyOf(checkNotNull(properties, "properties"));
|
||||||
private Status status = Status.UNRECOGNIZED;
|
|
||||||
// | is_public | tinyint(1) | NO | | NULL | |
|
|
||||||
@SerializedName("is_public")
|
|
||||||
private boolean isPublic;
|
|
||||||
private Map<String, String> properties = ImmutableMap.of();
|
|
||||||
|
|
||||||
protected ImageDetails(Builder<?> builder) {
|
|
||||||
super(builder);
|
|
||||||
this.minDisk = builder.minDisk;
|
|
||||||
this.minRam = checkNotNull(builder.minRam, "minRam");
|
|
||||||
this.location = checkNotNull(builder.location, "location");
|
|
||||||
this.owner = checkNotNull(builder.owner, "owner");
|
|
||||||
this.updatedAt = checkNotNull(builder.updatedAt, "updatedAt");
|
|
||||||
this.createdAt = checkNotNull(builder.createdAt, "createdAt");
|
|
||||||
this.deletedAt = checkNotNull(builder.deletedAt, "deletedAt");
|
|
||||||
this.status = checkNotNull(builder.status, "status");
|
|
||||||
this.isPublic = checkNotNull(builder.isPublic, "isPublic");
|
|
||||||
this.properties = ImmutableMap.copyOf(builder.properties);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -238,16 +223,12 @@ public class ImageDetails extends Image {
|
||||||
return this.minRam;
|
return this.minRam;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Status getStatus() {
|
|
||||||
return this.status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<String> getLocation() {
|
public Optional<String> getLocation() {
|
||||||
return this.location;
|
return this.location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<String> getOwner() {
|
public Optional<String> getOwner() {
|
||||||
return owner;
|
return this.owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getUpdatedAt() {
|
public Date getUpdatedAt() {
|
||||||
|
@ -262,22 +243,43 @@ public class ImageDetails extends Image {
|
||||||
return this.deletedAt;
|
return this.deletedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Image.Status getStatus() {
|
||||||
|
return this.status;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isPublic() {
|
public boolean isPublic() {
|
||||||
return this.isPublic;
|
return this.isPublic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getProperties() {
|
public Map<String, String> getProperties() {
|
||||||
// in case this was assigned in gson
|
return this.properties;
|
||||||
return ImmutableMap.copyOf(Maps.filterValues(this.properties, Predicates.notNull()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// hashCode/equals from super is ok
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(minDisk, minRam, location, owner, updatedAt, createdAt, deletedAt, status, isPublic, properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj) return true;
|
||||||
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
|
ImageDetails that = ImageDetails.class.cast(obj);
|
||||||
|
return super.equals(that) && Objects.equal(this.minDisk, that.minDisk)
|
||||||
|
&& Objects.equal(this.minRam, that.minRam)
|
||||||
|
&& Objects.equal(this.location, that.location)
|
||||||
|
&& Objects.equal(this.owner, that.owner)
|
||||||
|
&& Objects.equal(this.updatedAt, that.updatedAt)
|
||||||
|
&& Objects.equal(this.createdAt, that.createdAt)
|
||||||
|
&& Objects.equal(this.deletedAt, that.deletedAt)
|
||||||
|
&& Objects.equal(this.status, that.status)
|
||||||
|
&& Objects.equal(this.isPublic, that.isPublic)
|
||||||
|
&& Objects.equal(this.properties, that.properties);
|
||||||
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return super.string().add("minDisk", minDisk).add("minRam", minRam).add("location", location).add("deletedAt",
|
return super.string()
|
||||||
getDeletedAt()).add("updatedAt", updatedAt).add("createdAt", createdAt).add("status", status).add(
|
.add("minDisk", minDisk).add("minRam", minRam).add("location", location).add("owner", owner).add("updatedAt", updatedAt).add("createdAt", createdAt).add("deletedAt", deletedAt).add("status", status).add("isPublic", isPublic).add("properties", properties);
|
||||||
"location", location).add("owner", owner).add("isPublic", isPublic).add("properties", properties);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,21 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.glance.v1_0.functions;
|
package org.jclouds.openstack.glance.v1_0.functions;
|
||||||
|
|
||||||
import static org.jclouds.openstack.glance.v1_0.options.ImageField.CHECKSUM;
|
import static org.jclouds.openstack.glance.v1_0.options.ImageField.*;
|
||||||
import static org.jclouds.openstack.glance.v1_0.options.ImageField.CONTAINER_FORMAT;
|
|
||||||
import static org.jclouds.openstack.glance.v1_0.options.ImageField.CREATED_AT;
|
|
||||||
import static org.jclouds.openstack.glance.v1_0.options.ImageField.DELETED_AT;
|
|
||||||
import static org.jclouds.openstack.glance.v1_0.options.ImageField.DISK_FORMAT;
|
|
||||||
import static org.jclouds.openstack.glance.v1_0.options.ImageField.ID;
|
|
||||||
import static org.jclouds.openstack.glance.v1_0.options.ImageField.IS_PUBLIC;
|
|
||||||
import static org.jclouds.openstack.glance.v1_0.options.ImageField.LOCATION;
|
|
||||||
import static org.jclouds.openstack.glance.v1_0.options.ImageField.MIN_DISK;
|
|
||||||
import static org.jclouds.openstack.glance.v1_0.options.ImageField.MIN_RAM;
|
|
||||||
import static org.jclouds.openstack.glance.v1_0.options.ImageField.NAME;
|
|
||||||
import static org.jclouds.openstack.glance.v1_0.options.ImageField.OWNER;
|
|
||||||
import static org.jclouds.openstack.glance.v1_0.options.ImageField.SIZE;
|
|
||||||
import static org.jclouds.openstack.glance.v1_0.options.ImageField.STATUS;
|
|
||||||
import static org.jclouds.openstack.glance.v1_0.options.ImageField.UPDATED_AT;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@ -40,11 +26,10 @@ import org.jclouds.date.DateService;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.openstack.glance.v1_0.domain.ContainerFormat;
|
import org.jclouds.openstack.glance.v1_0.domain.ContainerFormat;
|
||||||
import org.jclouds.openstack.glance.v1_0.domain.DiskFormat;
|
import org.jclouds.openstack.glance.v1_0.domain.DiskFormat;
|
||||||
import org.jclouds.openstack.glance.v1_0.domain.ImageDetails;
|
|
||||||
import org.jclouds.openstack.glance.v1_0.domain.Image.Status;
|
import org.jclouds.openstack.glance.v1_0.domain.Image.Status;
|
||||||
|
import org.jclouds.openstack.glance.v1_0.domain.ImageDetails;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Optional;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This parses {@link ImageDetails} from HTTP headers.
|
* This parses {@link ImageDetails} from HTTP headers.
|
||||||
|
@ -63,14 +48,14 @@ public class ParseImageDetailsFromHeaders implements Function<HttpResponse, Imag
|
||||||
ImageDetails.Builder<?> builder = ImageDetails.builder()
|
ImageDetails.Builder<?> builder = ImageDetails.builder()
|
||||||
.id(from.getFirstHeaderOrNull(ID.asHeader()))
|
.id(from.getFirstHeaderOrNull(ID.asHeader()))
|
||||||
.name(from.getFirstHeaderOrNull(NAME.asHeader()))
|
.name(from.getFirstHeaderOrNull(NAME.asHeader()))
|
||||||
.checksum(Optional.fromNullable(from.getFirstHeaderOrNull(CHECKSUM.asHeader())))
|
.checksum(from.getFirstHeaderOrNull(CHECKSUM.asHeader()))
|
||||||
.minDisk(Long.parseLong(from.getFirstHeaderOrNull(MIN_DISK.asHeader())))
|
.minDisk(Long.parseLong(from.getFirstHeaderOrNull(MIN_DISK.asHeader())))
|
||||||
.minRam(Long.parseLong(from.getFirstHeaderOrNull(MIN_RAM.asHeader())))
|
.minRam(Long.parseLong(from.getFirstHeaderOrNull(MIN_RAM.asHeader())))
|
||||||
.isPublic(Boolean.parseBoolean(from.getFirstHeaderOrNull(IS_PUBLIC.asHeader())))
|
.isPublic(Boolean.parseBoolean(from.getFirstHeaderOrNull(IS_PUBLIC.asHeader())))
|
||||||
.createdAt(dateService.iso8601SecondsDateParse(from.getFirstHeaderOrNull(CREATED_AT.asHeader())))
|
.createdAt(dateService.iso8601SecondsDateParse(from.getFirstHeaderOrNull(CREATED_AT.asHeader())))
|
||||||
.updatedAt(dateService.iso8601SecondsDateParse(from.getFirstHeaderOrNull(UPDATED_AT.asHeader())))
|
.updatedAt(dateService.iso8601SecondsDateParse(from.getFirstHeaderOrNull(UPDATED_AT.asHeader())))
|
||||||
.owner(Optional.fromNullable(from.getFirstHeaderOrNull(OWNER.asHeader())))
|
.owner(from.getFirstHeaderOrNull(OWNER.asHeader()))
|
||||||
.location(Optional.fromNullable(from.getFirstHeaderOrNull(LOCATION.asHeader())))
|
.location(from.getFirstHeaderOrNull(LOCATION.asHeader()))
|
||||||
.status(Status.fromValue(from.getFirstHeaderOrNull(STATUS.asHeader())));
|
.status(Status.fromValue(from.getFirstHeaderOrNull(STATUS.asHeader())));
|
||||||
|
|
||||||
String containerFormat = from.getFirstHeaderOrNull(CONTAINER_FORMAT.asHeader());
|
String containerFormat = from.getFirstHeaderOrNull(CONTAINER_FORMAT.asHeader());
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class ParseImageDetailsTest extends BaseItemParserTest<ImageDetails> {
|
||||||
.containerFormat(ContainerFormat.BARE)
|
.containerFormat(ContainerFormat.BARE)
|
||||||
.diskFormat(DiskFormat.RAW)
|
.diskFormat(DiskFormat.RAW)
|
||||||
.checksum("6ae4e0fdc3c108a1bfe10ef5e436f4f4")
|
.checksum("6ae4e0fdc3c108a1bfe10ef5e436f4f4")
|
||||||
.size(27)
|
.size(27L)
|
||||||
.status(Image.Status.ACTIVE)
|
.status(Image.Status.ACTIVE)
|
||||||
.owner("68a7c7abb7bf45ada1536dfa28ec2115")
|
.owner("68a7c7abb7bf45ada1536dfa28ec2115")
|
||||||
.isPublic(false)
|
.isPublic(false)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.quantum.v1_0.domain;
|
package org.jclouds.openstack.quantum.v1_0.domain;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Quantum attachment
|
* A Quantum attachment
|
||||||
*
|
*
|
||||||
|
@ -35,10 +37,9 @@ public class Attachment extends Reference {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> extends Reference.Builder<T> {
|
public static abstract class Builder<T extends Builder<T>> extends Reference.Builder<T> {
|
||||||
protected abstract T self();
|
|
||||||
|
|
||||||
public Attachment build() {
|
public Attachment build() {
|
||||||
return new Attachment(this);
|
return new Attachment(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T fromAttachment(Attachment in) {
|
public T fromAttachment(Attachment in) {
|
||||||
|
@ -53,11 +54,12 @@ public class Attachment extends Reference {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Attachment(Builder<?> builder) {
|
|
||||||
super(builder);
|
@ConstructorProperties({
|
||||||
|
"id"
|
||||||
|
})
|
||||||
|
protected Attachment(String id) {
|
||||||
|
super(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Attachment() {
|
|
||||||
// for GSON
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,6 +20,17 @@ package org.jclouds.openstack.quantum.v1_0.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
|
||||||
|
@ -40,9 +51,7 @@ public class Network extends Reference {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> extends Reference.Builder<T> {
|
public static abstract class Builder<T extends Builder<T>> extends Reference.Builder<T> {
|
||||||
protected abstract T self();
|
protected String name;
|
||||||
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Network#getName()
|
* @see Network#getName()
|
||||||
|
@ -53,11 +62,12 @@ public class Network extends Reference {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Network build() {
|
public Network build() {
|
||||||
return new Network(this);
|
return new Network(id, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T fromNetwork(Network in) {
|
public T fromNetwork(Network in) {
|
||||||
return super.fromReference(in).name(in.getName());
|
return super.fromReference(in)
|
||||||
|
.name(in.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,25 +80,21 @@ public class Network extends Reference {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
protected Network(Builder<?> builder) {
|
@ConstructorProperties({
|
||||||
super(builder);
|
"id", "name"
|
||||||
this.name = checkNotNull(builder.name, "name");
|
})
|
||||||
|
protected Network(String id, String name) {
|
||||||
|
super(id);
|
||||||
|
this.name = checkNotNull(name, "name");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Network() {
|
|
||||||
// for GSON
|
|
||||||
this.name = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(super.hashCode(), name);
|
return Objects.hashCode(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -100,6 +106,8 @@ public class Network extends Reference {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return super.string().add("name", name);
|
return super.string()
|
||||||
|
.add("name", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,7 +20,7 @@ package org.jclouds.openstack.quantum.v1_0.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.beans.ConstructorProperties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
@ -44,13 +44,13 @@ public class NetworkDetails extends Network {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> extends Network.Builder<T> {
|
public static abstract class Builder<T extends Builder<T>> extends Network.Builder<T> {
|
||||||
private Set<Port> ports = ImmutableSet.of();
|
protected Set<Port> ports = ImmutableSet.of();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see NetworkDetails#getPorts()
|
* @see NetworkDetails#getPorts()
|
||||||
*/
|
*/
|
||||||
public T ports(Set<Port> ports) {
|
public T ports(Set<Port> ports) {
|
||||||
this.ports = ports;
|
this.ports = ImmutableSet.copyOf(checkNotNull(ports, "ports"));
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,11 +59,12 @@ public class NetworkDetails extends Network {
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetworkDetails build() {
|
public NetworkDetails build() {
|
||||||
return new NetworkDetails(this);
|
return new NetworkDetails(id, name, ports);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T fromNetworkDetails(NetworkDetails in) {
|
public T fromNetworkDetails(NetworkDetails in) {
|
||||||
return super.fromNetwork(in).ports(in.getPorts());
|
return super.fromNetwork(in)
|
||||||
|
.ports(in.getPorts());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,20 +77,16 @@ public class NetworkDetails extends Network {
|
||||||
|
|
||||||
private final Set<Port> ports;
|
private final Set<Port> ports;
|
||||||
|
|
||||||
protected NetworkDetails(Builder<?> builder) {
|
@ConstructorProperties({
|
||||||
super(builder);
|
"id", "name", "ports"
|
||||||
this.ports = ImmutableSet.copyOf(checkNotNull(builder.ports, "ports"));
|
})
|
||||||
|
protected NetworkDetails(String id, String name, Set<Port> ports) {
|
||||||
|
super(id, name);
|
||||||
|
this.ports = ImmutableSet.copyOf(checkNotNull(ports, "ports"));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected NetworkDetails() {
|
|
||||||
// for GSON
|
|
||||||
this.ports = ImmutableSet.of();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public Set<Port> getPorts() {
|
public Set<Port> getPorts() {
|
||||||
return Collections.unmodifiableSet(this.ports);
|
return this.ports;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -106,7 +103,8 @@ public class NetworkDetails extends Network {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return super.string().add("ports", ports);
|
return super.string()
|
||||||
|
.add("ports", ports);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,6 +20,8 @@ package org.jclouds.openstack.quantum.v1_0.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
|
||||||
|
@ -31,6 +33,8 @@ import com.google.common.base.Objects.ToStringHelper;
|
||||||
*/
|
*/
|
||||||
public class Port extends Reference {
|
public class Port extends Reference {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
public static enum State {
|
public static enum State {
|
||||||
ACTIVE, DOWN
|
ACTIVE, DOWN
|
||||||
}
|
}
|
||||||
|
@ -44,9 +48,7 @@ public class Port extends Reference {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> extends Reference.Builder<T> {
|
public static abstract class Builder<T extends Builder<T>> extends Reference.Builder<T> {
|
||||||
protected abstract T self();
|
protected Port.State state;
|
||||||
|
|
||||||
private Port.State state;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Port#getState()
|
* @see Port#getState()
|
||||||
|
@ -57,11 +59,12 @@ public class Port extends Reference {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Port build() {
|
public Port build() {
|
||||||
return new Port(this);
|
return new Port(id, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T fromPort(Port in) {
|
public T fromPort(Port in) {
|
||||||
return fromReference(in).state(in.getState());
|
return super.fromReference(in)
|
||||||
|
.state(in.getState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,14 +77,12 @@ public class Port extends Reference {
|
||||||
|
|
||||||
private final Port.State state;
|
private final Port.State state;
|
||||||
|
|
||||||
protected Port(Builder<?> builder) {
|
@ConstructorProperties({
|
||||||
super(builder);
|
"id", "state"
|
||||||
this.state = checkNotNull(builder.state, "state");
|
})
|
||||||
}
|
protected Port(String id, Port.State state) {
|
||||||
|
super(id);
|
||||||
protected Port() {
|
this.state = checkNotNull(state, "state");
|
||||||
// for GSON
|
|
||||||
this.state = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Port.State getState() {
|
public Port.State getState() {
|
||||||
|
@ -90,7 +91,7 @@ public class Port extends Reference {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(super.hashCode(), state);
|
return Objects.hashCode(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -102,6 +103,8 @@ public class Port extends Reference {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return super.string().add("state", state);
|
return super.string()
|
||||||
|
.add("state", state);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.quantum.v1_0.domain;
|
package org.jclouds.openstack.quantum.v1_0.domain;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
@ -40,7 +42,7 @@ public class PortDetails extends Port {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class Builder<T extends Builder<T>> extends Port.Builder<T> {
|
public static abstract class Builder<T extends Builder<T>> extends Port.Builder<T> {
|
||||||
private Attachment attachment;
|
protected Attachment attachment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see PortDetails#getAttachment()
|
* @see PortDetails#getAttachment()
|
||||||
|
@ -51,11 +53,12 @@ public class PortDetails extends Port {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PortDetails build() {
|
public PortDetails build() {
|
||||||
return new PortDetails(this);
|
return new PortDetails(id, state, attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T fromPortDetails(PortDetails in) {
|
public T fromPortDetails(PortDetails in) {
|
||||||
return super.fromPort(in).attachment(in.getAttachment());
|
return super.fromPort(in)
|
||||||
|
.attachment(in.getAttachment());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,17 +69,14 @@ public class PortDetails extends Port {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private final Attachment attachment;
|
private final Attachment attachment;
|
||||||
|
|
||||||
protected PortDetails(Builder<?> builder) {
|
@ConstructorProperties({
|
||||||
super(builder);
|
"id", "state", "attachment"
|
||||||
this.attachment = builder.attachment;
|
})
|
||||||
}
|
protected PortDetails(String id, Port.State state, @Nullable Attachment attachment) {
|
||||||
|
super(id, state);
|
||||||
protected PortDetails() {
|
this.attachment = attachment;
|
||||||
// for GSON
|
|
||||||
this.attachment = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -98,7 +98,8 @@ public class PortDetails extends Port {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return super.string().add("attachment", attachment);
|
return super.string()
|
||||||
|
.add("attachment", attachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
/**
|
/*
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||||
* contributor license agreements. See the NOTICE file
|
* contributor license agreements. See the NOTICE file
|
||||||
* distributed with this work for additional information
|
* distributed with this work for additional information
|
||||||
|
@ -20,6 +20,8 @@ package org.jclouds.openstack.quantum.v1_0.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
|
||||||
|
@ -42,10 +44,10 @@ public class Reference {
|
||||||
public static abstract class Builder<T extends Builder<T>> {
|
public static abstract class Builder<T extends Builder<T>> {
|
||||||
protected abstract T self();
|
protected abstract T self();
|
||||||
|
|
||||||
private String id;
|
protected String id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.jclouds.openstack.quantum.v1_0.domain.Reference#getId()
|
* @see Reference#getId()
|
||||||
*/
|
*/
|
||||||
public T id(String id) {
|
public T id(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
@ -53,11 +55,12 @@ public class Reference {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Reference build() {
|
public Reference build() {
|
||||||
return new Reference(this);
|
return new Reference(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public T fromReference(Reference in) {
|
public T fromReference(Reference in) {
|
||||||
return this.id(in.getId());
|
return this
|
||||||
|
.id(in.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,22 +73,17 @@ public class Reference {
|
||||||
|
|
||||||
private final String id;
|
private final String id;
|
||||||
|
|
||||||
protected Reference(Builder<?> builder) {
|
@ConstructorProperties({
|
||||||
this.id = checkNotNull(builder.id, "id");
|
"id"
|
||||||
|
})
|
||||||
|
protected Reference(String id) {
|
||||||
|
this.id = checkNotNull(id, "id");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Reference() {
|
|
||||||
// for GSON
|
|
||||||
this.id = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(id);
|
return Objects.hashCode(id);
|
||||||
|
@ -100,7 +98,8 @@ public class Reference {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToStringHelper string() {
|
protected ToStringHelper string() {
|
||||||
return Objects.toStringHelper("").add("id", id);
|
return Objects.toStringHelper(this)
|
||||||
|
.add("id", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,6 +3,8 @@ package org.jclouds.openstack.swift.v1.domain;
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.equal;
|
||||||
import static com.google.common.base.Objects.toStringHelper;
|
import static com.google.common.base.Objects.toStringHelper;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
|
||||||
|
@ -49,16 +51,11 @@ public class AccountMetadata {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AccountMetadata() {
|
|
||||||
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
|
|
||||||
// prohibited in GAE. This also implies fields are not final.
|
|
||||||
// see http://code.google.com/p/jclouds/issues/detail?id=925
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int containerCount;
|
protected int containerCount;
|
||||||
protected long bytesUsed;
|
protected long bytesUsed;
|
||||||
|
|
||||||
public AccountMetadata(int containerCount, long bytesUsed) {
|
@ConstructorProperties({"containerCount", "bytesUsed"})
|
||||||
|
protected AccountMetadata(int containerCount, long bytesUsed) {
|
||||||
this.containerCount = containerCount;
|
this.containerCount = containerCount;
|
||||||
this.bytesUsed = bytesUsed;
|
this.bytesUsed = bytesUsed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ import static com.google.common.base.Objects.equal;
|
||||||
import static com.google.common.base.Objects.toStringHelper;
|
import static com.google.common.base.Objects.toStringHelper;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.beans.ConstructorProperties;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
|
||||||
|
@ -65,17 +67,12 @@ public class ContainerMetadata implements Comparable<ContainerMetadata> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ContainerMetadata() {
|
|
||||||
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
|
|
||||||
// prohibited in GAE. This also implies fields are not final.
|
|
||||||
// see http://code.google.com/p/jclouds/issues/detail?id=925
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
protected int count;
|
protected int count;
|
||||||
protected int bytes;
|
protected int bytes;
|
||||||
|
|
||||||
public ContainerMetadata(String name, int count, int bytes) {
|
@ConstructorProperties({"name", "count", "bytes"})
|
||||||
|
protected ContainerMetadata(String name, int count, int bytes) {
|
||||||
this.name = checkNotNull(name, "name");
|
this.name = checkNotNull(name, "name");
|
||||||
this.count = count;
|
this.count = count;
|
||||||
this.bytes = bytes;
|
this.bytes = bytes;
|
||||||
|
|
Loading…
Reference in New Issue