Issue 925: added default ctors so that gson can work w/o using sun.misc.Unsafe

This commit is contained in:
Adrian Cole 2012-05-16 14:51:16 -07:00
parent c4499d8c5e
commit 96e272a91d
44 changed files with 474 additions and 294 deletions

View File

@ -75,9 +75,15 @@ public class Address {
return addr(from.getAddr()).version(from.getVersion()); return addr(from.getAddr()).version(from.getVersion());
} }
} }
protected final String addr; protected Address() {
protected final int version; // 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 addr;
protected int version;
public Address(String addr, int version) { public Address(String addr, int version) {
this.addr = addr; this.addr = addr;

View File

@ -105,11 +105,17 @@ public class Extension extends Resource {
return this; return this;
} }
} }
private final URI namespace; protected Extension() {
private final String alias; // we want serializers like Gson to work w/o using sun.misc.Unsafe,
private final Date updated; // prohibited in GAE. This also implies fields are not final.
private final String description; // see http://code.google.com/p/jclouds/issues/detail?id=925
}
private URI namespace;
private String alias;
private Date updated;
private String description;
protected Extension(Builder<?> builder) { protected Extension(Builder<?> builder) {
super(builder); super(builder);

View File

@ -122,15 +122,21 @@ public class Flavor extends Resource {
return this; return this;
} }
} }
protected Flavor() {
// 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
}
private int ram; private int ram;
private int disk; private int disk;
private int vcpus; private int vcpus;
private final Optional<String> swap; private Optional<String> swap = Optional.absent();
@SerializedName("rxtx_factor") @SerializedName("rxtx_factor")
private final Optional<Double> rxtxFactor; private Optional<Double> rxtxFactor = Optional.absent();
@SerializedName("OS-FLV-EXT-DATA:ephemeral") @SerializedName("OS-FLV-EXT-DATA:ephemeral")
private final Optional<Integer> ephemeral; private Optional<Integer> ephemeral = Optional.absent();
protected Flavor(Builder<?> builder) { protected Flavor(Builder<?> builder) {
super(builder); super(builder);
@ -142,12 +148,6 @@ public class Flavor extends Resource {
this.ephemeral = Optional.fromNullable(builder.ephemeral); this.ephemeral = Optional.fromNullable(builder.ephemeral);
} }
protected Flavor() {
this.swap = Optional.absent();
this.rxtxFactor = Optional.absent();
this.ephemeral = Optional.absent();
}
public int getRam() { public int getRam() {
return this.ram; return this.ram;
} }

View File

@ -76,7 +76,13 @@ public class FloatingIP implements Comparable<FloatingIP> {
} }
} }
protected FloatingIP() {
// 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
}
private String id; private String id;
private String ip; private String ip;
@SerializedName("fixed_ip") @SerializedName("fixed_ip")

View File

@ -72,10 +72,16 @@ public class Host {
return this; return this;
} }
} }
protected Host() {
// 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
}
@SerializedName(value="host_name") @SerializedName(value="host_name")
private final String name; private String name;
private final String service; private String service;
protected Host(Builder<?> builder) { protected Host(Builder<?> builder) {
this.name = builder.name; this.name = builder.name;

View File

@ -154,19 +154,25 @@ public class HostAggregate {
return this; return this;
} }
} }
private final String id; protected HostAggregate() {
private final String name; // 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
}
private String id;
private String name;
@SerializedName(value = "availability_zone") @SerializedName(value = "availability_zone")
private final String availabilityZone; private String availabilityZone;
private final Set<String> hosts; private Set<String> hosts = ImmutableSet.of();
@SerializedName(value = "operational_state") @SerializedName(value = "operational_state")
private final String state; private String state;
@SerializedName(value = "created_at") @SerializedName(value = "created_at")
private final Date created; private Date created;
@SerializedName(value = "updated_at") @SerializedName(value = "updated_at")
private final Optional<Date> updated; private Optional<Date> updated = Optional.absent();
private final Map<String, String> metadata; private Map<String, String> metadata = ImmutableMap.of();
protected HostAggregate(Builder<?> builder) { protected HostAggregate(Builder<?> builder) {
this.id = checkNotNull(builder.id, "id"); this.id = checkNotNull(builder.id, "id");
@ -179,18 +185,6 @@ public class HostAggregate {
this.metadata = ImmutableMap.copyOf(checkNotNull(builder.metadata, "metadata")); this.metadata = ImmutableMap.copyOf(checkNotNull(builder.metadata, "metadata"));
} }
// Ensure GSON parsed objects don't have null collections or optionals
protected HostAggregate() {
this.id = null;
this.name = null;
this.availabilityZone = null;
this.hosts = ImmutableSet.of();
this.state = null;
this.created = null;
this.updated = Optional.absent();
this.metadata = ImmutableMap.of();
}
public String getId() { public String getId() {
return this.id; return this.id;
} }

View File

@ -95,14 +95,20 @@ public class HostResourceUsage {
return this; return this;
} }
} }
private final String host; protected HostResourceUsage() {
private final String project; // 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
}
private String host;
private String project;
@SerializedName(value="memory_mb") @SerializedName(value="memory_mb")
private final int memoryMb; private int memoryMb;
private final int cpu; private int cpu;
@SerializedName(value="disk_gb") @SerializedName(value="disk_gb")
private final int diskGb; private int diskGb;
protected HostResourceUsage(Builder<?> builder) { protected HostResourceUsage(Builder<?> builder) {
this.host = checkNotNull(builder.host, "host"); this.host = checkNotNull(builder.host, "host");

View File

@ -191,19 +191,25 @@ public class Image extends Resource {
return this; return this;
} }
} }
private final Date updated; protected Image() {
private final Date created; // 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
}
private Date updated;
private Date created;
@SerializedName("tenant_id") @SerializedName("tenant_id")
private final String tenantId; private String tenantId;
@SerializedName("user_id") @SerializedName("user_id")
private final String userId; private String userId;
private final Status status; private Status status;
private final int progress; private int progress;
private final int minDisk; private int minDisk;
private final int minRam; private int minRam;
private final Resource server; private Resource server;
private final Map<String, String> metadata; private Map<String, String> metadata = ImmutableMap.of();
protected Image(Builder<?> builder) { protected Image(Builder<?> builder) {
super(builder); super(builder);

View File

@ -73,13 +73,19 @@ public class Ingress {
return new Ingress(ipProtocol, fromPort, toPort); return new Ingress(ipProtocol, fromPort, toPort);
} }
} }
protected Ingress() {
// 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
}
@SerializedName(value = "ip_protocol") @SerializedName(value = "ip_protocol")
protected final IpProtocol ipProtocol; protected IpProtocol ipProtocol;
@SerializedName(value = "from_port") @SerializedName(value = "from_port")
protected final int fromPort; protected int fromPort;
@SerializedName(value = "to_port") @SerializedName(value = "to_port")
protected final int toPort; protected int toPort;
protected Ingress(IpProtocol ipProtocol, int fromPort, int toPort) { protected Ingress(IpProtocol ipProtocol, int fromPort, int toPort) {
this.fromPort = fromPort; this.fromPort = fromPort;

View File

@ -76,15 +76,21 @@ public class KeyPair implements Comparable<KeyPair> {
} }
} }
protected KeyPair() {
// 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
}
@SerializedName("public_key") @SerializedName("public_key")
String publicKey; private String publicKey;
@SerializedName("private_key") @SerializedName("private_key")
String privateKey; private String privateKey;
@SerializedName("user_id") @SerializedName("user_id")
String userId; private String userId;
String name; private String name;
String fingerprint; private String fingerprint;
protected KeyPair(String publicKey, String privateKey, @Nullable String userId, String name, String fingerprint) { protected KeyPair(String publicKey, String privateKey, @Nullable String userId, String name, String fingerprint) {
this.publicKey = publicKey; this.publicKey = publicKey;

View File

@ -187,28 +187,34 @@ public class Quotas {
return this; return this;
} }
} }
protected Quotas() {
// 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
}
@SerializedName("id") @SerializedName("id")
private final String id; private String id;
@SerializedName("metadata_items") @SerializedName("metadata_items")
private final int metadataItems; private int metadataItems;
@SerializedName("injected_file_content_bytes") @SerializedName("injected_file_content_bytes")
private final int injectedFileContentBytes; private int injectedFileContentBytes;
private final int volumes; private int volumes;
private final int gigabytes; private int gigabytes;
private final int ram; private int ram;
@SerializedName("floating_ips") @SerializedName("floating_ips")
private final int floatingIps; private int floatingIps;
private final int instances; private int instances;
@SerializedName("injected_files") @SerializedName("injected_files")
private final int injectedFiles; private int injectedFiles;
private final int cores; private int cores;
@SerializedName("security_groups") @SerializedName("security_groups")
private final int securityGroups; private int securityGroups;
@SerializedName("security_group_rules") @SerializedName("security_group_rules")
private final int securityGroupRules; private int securityGroupRules;
@SerializedName("key_pairs") @SerializedName("key_pairs")
private final int keyPairs; private int keyPairs;
protected Quotas(Builder<?> builder) { protected Quotas(Builder<?> builder) {
this.id = checkNotNull(builder.id, "id"); this.id = checkNotNull(builder.id, "id");

View File

@ -102,13 +102,19 @@ public class SecurityGroup {
} }
} }
protected final String id; protected SecurityGroup() {
// 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 id;
@SerializedName("tenant_id") @SerializedName("tenant_id")
protected final String tenantId; protected String tenantId;
protected final String name; protected String name;
protected final String description; protected String description;
protected final Set<SecurityGroupRule> rules; protected Set<SecurityGroupRule> rules = ImmutableSet.of();
protected SecurityGroup(String id, String tenantId, @Nullable String name, @Nullable String description, protected SecurityGroup(String id, String tenantId, @Nullable String name, @Nullable String description,
Set<SecurityGroupRule> rules) { Set<SecurityGroupRule> rules) {

View File

@ -95,13 +95,19 @@ public class SecurityGroupRule extends Ingress {
} }
} }
protected final String id; protected SecurityGroupRule() {
// we want serializers like Gson to work w/o using sun.misc.Unsafe,
protected final TenantIdAndName group; // prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
protected String id;
protected TenantIdAndName group;
@SerializedName(value = "parent_group_id") @SerializedName(value = "parent_group_id")
protected final String parentGroupId; protected String parentGroupId;
@SerializedName(value = "ip_range")
protected Cidr ipRange;
// type to get around unnecessary structure // type to get around unnecessary structure
private static class Cidr extends ForwardingObject { private static class Cidr extends ForwardingObject {
@ -117,8 +123,6 @@ public class SecurityGroupRule extends Ingress {
} }
} }
@SerializedName(value = "ip_range")
protected final Cidr ipRange;
protected SecurityGroupRule(IpProtocol ipProtocol, int fromPort, int toPort, String id, String parentGroupId, protected SecurityGroupRule(IpProtocol ipProtocol, int fromPort, int toPort, String id, String parentGroupId,
@Nullable TenantIdAndName group, @Nullable String ipRange) { @Nullable TenantIdAndName group, @Nullable String ipRange) {

View File

@ -34,7 +34,6 @@ import com.google.common.base.Objects.ToStringHelper;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
@ -302,38 +301,41 @@ public class Server extends Resource {
} }
} }
private final String uuid; protected Server() {
// 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
}
private String uuid;
@SerializedName("tenant_id") @SerializedName("tenant_id")
private final String tenantId; private String tenantId;
@SerializedName("user_id") @SerializedName("user_id")
private final String userId; private String userId;
private final Date updated; private Date updated;
private final Date created; private Date created;
private final String hostId; private String hostId;
private final String accessIPv4; private String accessIPv4;
private final String accessIPv6; private String accessIPv6;
private final Status status; private Status status;
private final Resource image; private Resource image;
private final Resource flavor; private Resource flavor;
@SerializedName("key_name") @SerializedName("key_name")
private final String keyName; private String keyName;
@SerializedName("config_drive") @SerializedName("config_drive")
private final String configDrive; private String configDrive;
// TODO: get gson multimap adapter! // TODO: get gson multimap adapter!
private final Map<String, Set<Address>> addresses; private Map<String, Set<Address>> addresses = ImmutableMap.of();
private final Map<String, String> metadata; private Map<String, String> metadata = ImmutableMap.of();
// Extended status extension // Extended status extension
// @Prefixed("OS-EXT-STS:") // @Prefixed("OS-EXT-STS:")
private final Optional<ServerExtendedStatus> extendedStatus; private Optional<ServerExtendedStatus> extendedStatus = Optional.absent();
// Extended server attributes extension // Extended server attributes extension
// @Prefixed("OS-EXT-SRV-ATTR:") // @Prefixed("OS-EXT-SRV-ATTR:")
private final Optional<ServerExtendedAttributes> extendedAttributes; private Optional<ServerExtendedAttributes> extendedAttributes = Optional.absent();
// Disk Config extension // Disk Config extension
@SerializedName("OS-DCF:diskConfig") @SerializedName("OS-DCF:diskConfig")
private final Optional<String> diskConfig; private Optional<String> diskConfig = Optional.absent();
protected Server(Builder<?> builder) { protected Server(Builder<?> builder) {
super(builder); super(builder);
@ -357,28 +359,6 @@ public class Server extends Resource {
this.diskConfig = builder.diskConfig == null ? Optional.<String>absent() : Optional.of(builder.diskConfig); this.diskConfig = builder.diskConfig == null ? Optional.<String>absent() : Optional.of(builder.diskConfig);
} }
protected Server() {
// for GSON
this.uuid = null;
this.tenantId = null;
this.userId = null;
this.updated = null;
this.created = null;
this.hostId = null;
this.accessIPv4 = null;
this.accessIPv6 = null;
this.status = null;
this.configDrive = null;
this.image = null;
this.flavor = null;
this.metadata = ImmutableMap.of();
this.addresses = ImmutableMap.of();
this.keyName = null;
this.extendedStatus = Optional.absent();
this.extendedAttributes = Optional.absent();
this.diskConfig = Optional.absent();
}
/** /**
* only present until the id is in uuid form * only present until the id is in uuid form
* *

View File

@ -18,7 +18,6 @@
*/ */
package org.jclouds.openstack.nova.v1_1.domain; package org.jclouds.openstack.nova.v1_1.domain;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.openstack.domain.Resource; import org.jclouds.openstack.domain.Resource;
import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Objects.ToStringHelper;
@ -68,17 +67,19 @@ public class ServerCreated extends Resource {
} }
} }
private final String adminPass; protected ServerCreated() {
// 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
}
private String adminPass;
protected ServerCreated(Builder<?> builder) { protected ServerCreated(Builder<?> builder) {
super(builder); super(builder);
this.adminPass = builder.adminPass; this.adminPass = builder.adminPass;
} }
protected ServerCreated() {
this.adminPass =null;
}
/** /**
* @return the administrative password for this server. Note: this is not available in Server responses. * @return the administrative password for this server. Note: this is not available in Server responses.
*/ */

View File

@ -93,12 +93,18 @@ public class ServerExtendedAttributes {
} }
} }
protected ServerExtendedAttributes() {
// 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
}
@SerializedName(value=PREFIX + "instance_name") @SerializedName(value=PREFIX + "instance_name")
private final String instanceName; private String instanceName;
@SerializedName(value=PREFIX + "host") @SerializedName(value=PREFIX + "host")
private final String hostName; private String hostName;
@SerializedName(value=PREFIX + "hypervisor_hostname") @SerializedName(value=PREFIX + "hypervisor_hostname")
private final String hypervisorHostName; private String hypervisorHostName;
protected ServerExtendedAttributes(Builder<?> builder) { protected ServerExtendedAttributes(Builder<?> builder) {
this.instanceName = builder.instanceName; this.instanceName = builder.instanceName;

View File

@ -94,25 +94,25 @@ public class ServerExtendedStatus {
return this; return this;
} }
} }
protected ServerExtendedStatus() {
// 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
}
@SerializedName(value=PREFIX + "task_state") @SerializedName(value=PREFIX + "task_state")
private final String taskState; private String taskState;
@SerializedName(value=PREFIX + "vm_state") @SerializedName(value=PREFIX + "vm_state")
private final String vmState; private String vmState;
@SerializedName(value=PREFIX + "power_state") @SerializedName(value=PREFIX + "power_state")
private final int powerState; private int powerState = Integer.MIN_VALUE;
protected ServerExtendedStatus(Builder<?> builder) { protected ServerExtendedStatus(Builder<?> builder) {
this.taskState = builder.taskState; this.taskState = builder.taskState;
this.vmState = builder.vmState; this.vmState = builder.vmState;
this.powerState = builder.powerState; this.powerState = builder.powerState;
} }
protected ServerExtendedStatus() {
this.taskState = null;
this.vmState = null;
this.powerState = Integer.MIN_VALUE;
}
@Nullable @Nullable
public String getTaskState() { public String getTaskState() {

View File

@ -73,9 +73,15 @@ public class ServerWithSecurityGroups extends Server {
return this; return this;
} }
} }
protected ServerWithSecurityGroups() {
// 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
}
@SerializedName(value="security_groups") @SerializedName(value="security_groups")
private final Set<String> securityGroupNames; private Set<String> securityGroupNames = ImmutableSet.of();
protected ServerWithSecurityGroups(Builder<?> builder) { protected ServerWithSecurityGroups(Builder<?> builder) {
super(builder); super(builder);

View File

@ -159,27 +159,33 @@ public class SimpleServerUsage {
return this; return this;
} }
} }
protected SimpleServerUsage() {
// 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
}
@SerializedName("name") @SerializedName("name")
private final String instanceName; private String instanceName;
private final double hours; private double hours;
@SerializedName("memory_mb") @SerializedName("memory_mb")
private final double flavorMemoryMb; private double flavorMemoryMb;
@SerializedName("local_gb") @SerializedName("local_gb")
private final double flavorLocalGb; private double flavorLocalGb;
@SerializedName("vcpus") @SerializedName("vcpus")
private final double flavorVcpus; private double flavorVcpus;
@SerializedName("tenant_id") @SerializedName("tenant_id")
private final String tenantId; private String tenantId;
@SerializedName("flavor") @SerializedName("flavor")
private final String flavorName; private String flavorName;
@SerializedName("started_at") @SerializedName("started_at")
private final Date instanceCreated; private Date instanceCreated;
@SerializedName("ended_at") @SerializedName("ended_at")
private final Date instanceTerminiated; private Date instanceTerminiated;
@SerializedName("state") @SerializedName("state")
private final Status instanceStatus; private Status instanceStatus;
private final long uptime; private long uptime;
private SimpleServerUsage(Builder<?> builder) { private SimpleServerUsage(Builder<?> builder) {
this.instanceName = checkNotNull(builder.instanceName, "instanceName"); this.instanceName = checkNotNull(builder.instanceName, "instanceName");

View File

@ -123,21 +123,27 @@ public class SimpleTenantUsage {
return this; return this;
} }
} }
protected SimpleTenantUsage() {
// 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
}
@SerializedName("tenant_id") @SerializedName("tenant_id")
private final String tenantId; private String tenantId;
@SerializedName("total_local_gb_usage") @SerializedName("total_local_gb_usage")
private final double totalLocalGbUsage; private double totalLocalGbUsage;
@SerializedName("total_vcpus_usage") @SerializedName("total_vcpus_usage")
private final double totalVcpusUsage; private double totalVcpusUsage;
@SerializedName("total_memory_mb_usage") @SerializedName("total_memory_mb_usage")
private final double totalMemoryMbUsage; private double totalMemoryMbUsage;
@SerializedName("total_hours") @SerializedName("total_hours")
private final double totalHours; private double totalHours;
private final Date start; private Date start;
private final Date stop; private Date stop;
@SerializedName("server_usages") @SerializedName("server_usages")
private final Set<SimpleServerUsage> serverUsages; private Set<SimpleServerUsage> serverUsages = ImmutableSet.of();
private SimpleTenantUsage(Builder<?> builder) { private SimpleTenantUsage(Builder<?> builder) {
this.tenantId = builder.tenantId; this.tenantId = builder.tenantId;

View File

@ -31,9 +31,15 @@ import com.google.gson.annotations.SerializedName;
*/ */
public class TenantIdAndName { public class TenantIdAndName {
protected TenantIdAndName() {
// 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
}
@SerializedName("tenant_id") @SerializedName("tenant_id")
protected final String tenantId; protected String tenantId;
protected final String name; protected String name;
public TenantIdAndName(String tenantId, String name) { public TenantIdAndName(String tenantId, String name) {
this.tenantId = checkNotNull(tenantId, "tenantId"); this.tenantId = checkNotNull(tenantId, "tenantId");

View File

@ -82,9 +82,15 @@ public class VirtualInterface {
} }
} }
private final String id; protected VirtualInterface() {
// 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
}
private String id;
@SerializedName(value="mac_address") @SerializedName(value="mac_address")
private final String macAddress; private String macAddress;
protected VirtualInterface(Builder<?> builder) { protected VirtualInterface(Builder<?> builder) {
this.id = checkNotNull(builder.id, "id"); this.id = checkNotNull(builder.id, "id");

View File

@ -177,21 +177,27 @@ public class Volume {
} }
} }
private final String id; protected Volume() {
private final Status status; // we want serializers like Gson to work w/o using sun.misc.Unsafe,
private final int size; // prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
private String id;
private Status status;
private int size;
@SerializedName(value="availabilityZone") @SerializedName(value="availabilityZone")
private final String zone; private String zone;
@SerializedName(value="createdAt") @SerializedName(value="createdAt")
private final Date created; private Date created;
private final Set<VolumeAttachment> attachments; private Set<VolumeAttachment> attachments = ImmutableSet.of();
private final String volumeType; private String volumeType;
private final String snapshotId; private String snapshotId;
@SerializedName(value="displayName") @SerializedName(value="displayName")
private final String name; private String name;
@SerializedName(value="displayDescription") @SerializedName(value="displayDescription")
private final String description; private String description;
private final Map<String, String> metadata; private Map<String, String> metadata = ImmutableMap.of();
protected Volume(Builder<?> builder) { protected Volume(Builder<?> builder) {
this.id = builder.id; this.id = builder.id;

View File

@ -92,10 +92,16 @@ public class VolumeAttachment {
} }
} }
private final String id; protected VolumeAttachment() {
private final String volumeId; // we want serializers like Gson to work w/o using sun.misc.Unsafe,
private final String serverId; // prohibited in GAE. This also implies fields are not final.
private final String device; // see http://code.google.com/p/jclouds/issues/detail?id=925
}
private String id;
private String volumeId;
private String serverId;
private String device;
protected VolumeAttachment(Builder<?> builder) { protected VolumeAttachment(Builder<?> builder) {
this.id = checkNotNull(builder.id, "id"); this.id = checkNotNull(builder.id, "id");

View File

@ -119,16 +119,22 @@ public class VolumeSnapshot {
} }
} }
private final String id; protected VolumeSnapshot() {
private final String volumeId; // we want serializers like Gson to work w/o using sun.misc.Unsafe,
private final Volume.Status status; // prohibited in GAE. This also implies fields are not final.
private final int size; // see http://code.google.com/p/jclouds/issues/detail?id=925
}
private String id;
private String volumeId;
private Volume.Status status;
private int size;
@SerializedName(value="createdAt") @SerializedName(value="createdAt")
private final Date created; private Date created;
@SerializedName(value="displayName") @SerializedName(value="displayName")
private final String name; private String name;
@SerializedName(value="displayDescription") @SerializedName(value="displayDescription")
private final String description; private String description;
protected VolumeSnapshot(Builder<?> builder) { protected VolumeSnapshot(Builder<?> builder) {
this.id = checkNotNull(builder.id, "id"); this.id = checkNotNull(builder.id, "id");

View File

@ -116,14 +116,20 @@ public class VolumeType {
} }
} }
protected VolumeType() {
// 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
}
private String id; private String id;
private String name; private String name;
@SerializedName("created_at") @SerializedName("created_at")
private Date created; private Date created;
@SerializedName("updated_at") @SerializedName("updated_at")
private final Optional<Date> updated; private Optional<Date> updated = Optional.absent();
@SerializedName(value = "extra_specs") @SerializedName(value = "extra_specs")
private final Map<String, String> extraSpecs; private Map<String, String> extraSpecs = ImmutableMap.of();
protected VolumeType(Builder<?> builder) { protected VolumeType(Builder<?> builder) {
this.id = checkNotNull(builder.id, "id"); this.id = checkNotNull(builder.id, "id");
@ -133,11 +139,6 @@ public class VolumeType {
this.updated = Optional.fromNullable(builder.updated); this.updated = Optional.fromNullable(builder.updated);
} }
protected VolumeType() {
this.updated = Optional.absent();
this.extraSpecs = ImmutableMap.of();
}
public String getId() { public String getId() {
return this.id; return this.id;
} }

View File

@ -28,7 +28,7 @@ import com.google.common.collect.ImmutableMap;
public class AuthenticationResponse { public class AuthenticationResponse {
private final String authToken; private final String authToken;
private Map<String, URI> services; private final Map<String, URI> services;
public AuthenticationResponse(String authToken, Map<String, URI> services) { public AuthenticationResponse(String authToken, Map<String, URI> services) {
this.authToken = checkNotNull(authToken, "authToken"); this.authToken = checkNotNull(authToken, "authToken");
@ -38,11 +38,7 @@ public class AuthenticationResponse {
public Map<String, URI> getServices() { public Map<String, URI> getServices() {
return services; return services;
} }
public void setEndpoints(Map<String, URI> services) {
this.services = services;
}
public String getAuthToken() { public String getAuthToken() {
return authToken; return authToken;
} }

View File

@ -133,11 +133,17 @@ public class Link {
return relation(from.getRelation()).type(from.getType()).href(from.getHref()); return relation(from.getRelation()).type(from.getType()).href(from.getHref());
} }
} }
protected Link() {
// 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
}
@SerializedName("rel") @SerializedName("rel")
protected final Relation relation; protected Relation relation;
protected final String type; protected String type;
protected final URI href; protected URI href;
protected Link(Relation relation, @Nullable String type, URI href) { protected Link(Relation relation, @Nullable String type, URI href) {
this.relation = checkNotNull(relation, "relation"); this.relation = checkNotNull(relation, "relation");

View File

@ -105,23 +105,23 @@ public class Resource implements Comparable<Resource> {
return this; return this;
} }
} }
protected Resource() {
// 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
}
private final String id; private String id;
private final String name; private String name;
private final Set<Link> links; private Set<Link> links = ImmutableSet.of();
protected Resource(Builder<?> builder) { protected Resource(Builder<?> builder) {
this.id = checkNotNull(builder.id, "id"); this.id = checkNotNull(builder.id, "id");
this.name = builder.name; this.name = builder.name;
this.links = ImmutableSet.copyOf(checkNotNull(builder.links, "links")); this.links = ImmutableSet.copyOf(checkNotNull(builder.links, "links"));
} }
protected Resource() {
this.id = null;
this.name = null;
this.links = ImmutableSet.of();
}
/** /**
* When providing an ID, it is assumed that the resource exists in the current OpenStack * When providing an ID, it is assumed that the resource exists in the current OpenStack
* deployment * deployment

View File

@ -28,6 +28,7 @@ import java.util.Set;
import org.jclouds.util.Multimaps2; import org.jclouds.util.Multimaps2;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
@ -78,9 +79,15 @@ public class Auth implements Comparable<Auth> {
} }
} }
protected final Token token; protected Auth() {
// 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 Token token;
// TODO: get gson multimap adapter! // TODO: get gson multimap adapter!
protected final Map<String, Set<Endpoint>> serviceCatalog; protected Map<String, Set<Endpoint>> serviceCatalog = ImmutableMap.of();
public Auth(Token token, Multimap<String, Endpoint> serviceCatalog) { public Auth(Token token, Multimap<String, Endpoint> serviceCatalog) {
this.token = checkNotNull(token, "token"); this.token = checkNotNull(token, "token");

View File

@ -99,10 +99,16 @@ public class Endpoint implements Comparable<Endpoint> {
} }
} }
protected final boolean v1Default; protected Endpoint() {
protected final String region; // we want serializers like Gson to work w/o using sun.misc.Unsafe,
protected final URI publicURL; // prohibited in GAE. This also implies fields are not final.
protected final URI internalURL; // see http://code.google.com/p/jclouds/issues/detail?id=925
}
protected boolean v1Default;
protected String region;
protected URI publicURL;
protected URI internalURL;
protected Endpoint(boolean v1Default, @Nullable String region, @Nullable URI publicURL, @Nullable URI internalURL) { protected Endpoint(boolean v1Default, @Nullable String region, @Nullable URI publicURL, @Nullable URI internalURL) {
this.v1Default = v1Default; this.v1Default = v1Default;

View File

@ -80,8 +80,14 @@ public class Token implements Comparable<Token> {
} }
} }
protected final String id; protected Token() {
protected final Date expires; // 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 id;
protected Date expires;
public Token(String id, Date expires) { public Token(String id, Date expires) {
this.id = checkNotNull(id, "id"); this.id = checkNotNull(id, "id");

View File

@ -89,9 +89,16 @@ public class Access implements Comparable<Access> {
} }
} }
protected final Token token;
protected final User user; protected Access() {
protected final Set<Service> serviceCatalog; // 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 Token token;
protected User user;
protected Set<Service> serviceCatalog = ImmutableSet.of();
public Access(Token token, User user, Set<Service> serviceCatalog) { public Access(Token token, User user, Set<Service> serviceCatalog) {
this.token = checkNotNull(token, "token"); this.token = checkNotNull(token, "token");

View File

@ -94,14 +94,20 @@ public class ApiMetadata extends Resource {
return this; return this;
} }
} }
protected ApiMetadata() {
// 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
}
@Nullable @Nullable
private final String status; private String status;
@Nullable @Nullable
private final Date updated; private Date updated;
@SerializedName(value="media-types") @SerializedName(value="media-types")
@Nullable @Nullable
private final Set<MediaType> mediaTypes; private Set<MediaType> mediaTypes = ImmutableSet.of();
protected ApiMetadata(Builder<?> builder) { protected ApiMetadata(Builder<?> builder) {
super(builder); super(builder);

View File

@ -115,19 +115,26 @@ public class Endpoint implements Comparable<Endpoint> {
from.getInternalURL()).tenantId(from.getTenantId()); from.getInternalURL()).tenantId(from.getTenantId());
} }
} }
protected Endpoint() {
// 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
}
// renamed half-way through // renamed half-way through
@Deprecated @Deprecated
protected String id; protected String id;
protected final String versionId; protected String versionId;
protected final String region; protected String region;
protected final URI publicURL; protected URI publicURL;
protected final URI internalURL; protected URI internalURL;
protected final URI adminURL; protected URI adminURL;
// renamed half-way through // renamed half-way through
@Deprecated @Deprecated
protected String tenantName; protected String tenantName;
protected final String tenantId; protected String tenantId;
protected Endpoint(String versionId, String region, @Nullable URI publicURL, @Nullable URI internalURL, protected Endpoint(String versionId, String region, @Nullable URI publicURL, @Nullable URI internalURL,
@Nullable URI adminURL, @Nullable String tenantId) { @Nullable URI adminURL, @Nullable String tenantId) {

View File

@ -59,9 +59,15 @@ public class MediaType {
return this.base(in.getBase()).type(in.getType()); return this.base(in.getBase()).type(in.getType());
} }
} }
private final String base; protected MediaType() {
private final String type; // 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
}
private String base;
private String type;
protected MediaType(Builder builder) { protected MediaType(Builder builder) {
this.base = builder.base; this.base = builder.base;

View File

@ -96,14 +96,20 @@ public class Role implements Comparable<Role> {
return id(from.getId()).name(from.getName()).serviceId(from.getServiceId()).tenantId(from.getTenantId()); return id(from.getId()).name(from.getName()).serviceId(from.getServiceId()).tenantId(from.getTenantId());
} }
} }
protected final String id; protected Role() {
protected final String name; // we want serializers like Gson to work w/o using sun.misc.Unsafe,
protected final String serviceId; // prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
protected String id;
protected String name;
protected String serviceId;
// renamed half-way through // renamed half-way through
@Deprecated @Deprecated
protected String tenantName; protected String tenantName;
protected final String tenantId; protected String tenantId;
protected Role(String id, String name, @Nullable String serviceId, @Nullable String tenantId) { protected Role(String id, String name, @Nullable String serviceId, @Nullable String tenantId) {
this.id = checkNotNull(id, "id"); this.id = checkNotNull(id, "id");

View File

@ -90,10 +90,16 @@ public class Service implements Comparable<Service> {
return type(from.getType()).name(from.getName()).endpoints(from.getEndpoints()); return type(from.getType()).name(from.getName()).endpoints(from.getEndpoints());
} }
} }
protected final String type; protected Service() {
protected final String name; // we want serializers like Gson to work w/o using sun.misc.Unsafe,
protected final Set<Endpoint> endpoints; // prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
protected String type;
protected String name;
protected Set<Endpoint> endpoints = ImmutableSet.of();
public Service(String type, String name, Set<Endpoint> endpoints) { public Service(String type, String name, Set<Endpoint> endpoints) {
this.type = checkNotNull(type, "type"); this.type = checkNotNull(type, "type");

View File

@ -82,10 +82,16 @@ public class Tenant implements Comparable<Tenant> {
return id(from.getId()).name(from.getName()); return id(from.getId()).name(from.getName());
} }
} }
protected final String id; protected Tenant() {
protected final String name; // we want serializers like Gson to work w/o using sun.misc.Unsafe,
protected final String description; // prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
protected String id;
protected String name;
protected String description;
protected Tenant(String id, String name, String description) { protected Tenant(String id, String name, String description) {
this.id = checkNotNull(id, "id"); this.id = checkNotNull(id, "id");

View File

@ -87,10 +87,16 @@ public class Token implements Comparable<Token> {
return id(from.getId()).expires(from.getExpires()).tenant(from.getTenant()); return id(from.getId()).expires(from.getExpires()).tenant(from.getTenant());
} }
} }
protected final String id; protected Token() {
protected final Date expires; // we want serializers like Gson to work w/o using sun.misc.Unsafe,
protected final Tenant tenant; // prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
protected String id;
protected Date expires;
protected Tenant tenant;
public Token(String id, Date expires, Tenant tenant) { public Token(String id, Date expires, Tenant tenant) {
this.id = checkNotNull(id, "id"); this.id = checkNotNull(id, "id");

View File

@ -93,22 +93,22 @@ public class User implements Comparable<User> {
return id(from.getId()).name(from.getName()).roles(from.getRoles()); return id(from.getId()).name(from.getName()).roles(from.getRoles());
} }
} }
protected final String id; protected User() {
protected final String name; // we want serializers like Gson to work w/o using sun.misc.Unsafe,
protected final Set<Role> roles; // prohibited in GAE. This also implies fields are not final.
// see http://code.google.com/p/jclouds/issues/detail?id=925
}
protected String id;
protected String name;
protected Set<Role> roles = ImmutableSet.of();
protected User(String id, String name, Set<Role> roles) { protected User(String id, String name, Set<Role> roles) {
this.id = checkNotNull(id, "id"); this.id = checkNotNull(id, "id");
this.name = checkNotNull(name, "name"); this.name = checkNotNull(name, "name");
this.roles = ImmutableSet.copyOf(checkNotNull(roles, "roles")); this.roles = ImmutableSet.copyOf(checkNotNull(roles, "roles"));
} }
protected User() {
id = null;
name = null;
roles = ImmutableSet.of();
}
/** /**
* When providing an ID, it is assumed that the user exists in the current OpenStack deployment * When providing an ID, it is assumed that the user exists in the current OpenStack deployment

View File

@ -49,8 +49,14 @@ public class AccountMetadata {
} }
} }
protected final int containerCount; protected AccountMetadata() {
protected final long bytesUsed; // 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 long bytesUsed;
public AccountMetadata(int containerCount, long bytesUsed) { public AccountMetadata(int containerCount, long bytesUsed) {
this.containerCount = containerCount; this.containerCount = containerCount;

View File

@ -65,9 +65,15 @@ public class ContainerMetadata implements Comparable<ContainerMetadata> {
} }
} }
protected final String name; protected ContainerMetadata() {
protected final int count; // we want serializers like Gson to work w/o using sun.misc.Unsafe,
protected final int bytes; // 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 int count;
protected int bytes;
public ContainerMetadata(String name, int count, int bytes) { public ContainerMetadata(String name, int count, int bytes) {
this.name = checkNotNull(name, "name"); this.name = checkNotNull(name, "name");

View File

@ -28,6 +28,12 @@ import com.google.gson.annotations.SerializedName;
* *
*/ */
public class ContainerCDNMetadata implements Comparable<ContainerCDNMetadata> { public class ContainerCDNMetadata implements Comparable<ContainerCDNMetadata> {
protected ContainerCDNMetadata() {
// 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
}
private String name; private String name;
private boolean cdn_enabled; private boolean cdn_enabled;
@ -45,9 +51,6 @@ public class ContainerCDNMetadata implements Comparable<ContainerCDNMetadata> {
this.cdn_uri = cdnUri; this.cdn_uri = cdnUri;
} }
public ContainerCDNMetadata() {
}
/** /**
* Beware: The container name is not available from HEAD CDN responses and will be null. return * Beware: The container name is not available from HEAD CDN responses and will be null. return
* the name of the container to which these CDN settings apply. * the name of the container to which these CDN settings apply.