mirror of https://github.com/apache/jclouds.git
Make links nullable
This commit is contained in:
parent
1d192dfe56
commit
112c64e92a
|
@ -49,7 +49,7 @@ public class Resource implements Comparable<Resource> {
|
||||||
|
|
||||||
protected String id;
|
protected String id;
|
||||||
protected String name;
|
protected String name;
|
||||||
protected Set<Link> links = ImmutableSet.of();
|
protected Set<Link> links;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see Resource#getId()
|
* @see Resource#getId()
|
||||||
|
@ -71,12 +71,12 @@ public class Resource implements Comparable<Resource> {
|
||||||
* @see Resource#getLinks()
|
* @see Resource#getLinks()
|
||||||
*/
|
*/
|
||||||
public T links(Set<Link> links) {
|
public T links(Set<Link> links) {
|
||||||
this.links = ImmutableSet.copyOf(checkNotNull(links, "links"));
|
this.links = links == null ? null : ImmutableSet.copyOf(links);
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
public T links(Link... in) {
|
public T links(Link... in) {
|
||||||
return links(ImmutableSet.copyOf(in));
|
return links(in == null ? null : ImmutableSet.copyOf(in));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Resource build() {
|
public Resource build() {
|
||||||
|
@ -108,7 +108,7 @@ public class Resource implements Comparable<Resource> {
|
||||||
protected Resource(String id, @Nullable String name, @Nullable 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 = links == null ? ImmutableSet.<Link>of() : ImmutableSet.copyOf(checkNotNull(links, "links"));
|
this.links = links == null ? null : ImmutableSet.copyOf(links);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -132,6 +132,7 @@ public class Resource implements Comparable<Resource> {
|
||||||
/**
|
/**
|
||||||
* @return the links of the id address allocated to the new server
|
* @return the links of the id address allocated to the new server
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
public Set<Link> getLinks() {
|
public Set<Link> getLinks() {
|
||||||
return this.links;
|
return this.links;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.jclouds.json.BaseSetParserTest;
|
||||||
import org.jclouds.json.config.GsonModule;
|
import org.jclouds.json.config.GsonModule;
|
||||||
import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
|
import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
|
||||||
import org.jclouds.openstack.v2_0.domain.Extension;
|
import org.jclouds.openstack.v2_0.domain.Extension;
|
||||||
|
import org.jclouds.openstack.v2_0.domain.Link;
|
||||||
import org.jclouds.rest.annotations.SelectJson;
|
import org.jclouds.rest.annotations.SelectJson;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -47,22 +48,25 @@ public class ParseExtensionListNormalTest extends BaseSetParserTest<Extension> {
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Set<Extension> expected() {
|
public Set<Extension> expected() {
|
||||||
return ImmutableSet.of(
|
return ImmutableSet.of(
|
||||||
Extension.builder().alias("os-keypairs").name("Keypairs")
|
Extension.builder().alias("os-keypairs").name("Keypairs").namespace(URI.create("http://docs.openstack.org/ext/keypairs/api/v1.1"))
|
||||||
.namespace(URI.create("http://docs.openstack.org/ext/keypairs/api/v1.1"))
|
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-08-08T00:00:00+00:00")).description("Keypair Support")
|
||||||
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-08-08T00:00:00+00:00"))
|
.links(Link.builder().relation(Link.Relation.SELF).href(URI.create("http://docs.openstack.org/ext/keypairs/api/v1.1")).build())
|
||||||
.description("Keypair Support").build(),
|
.build(),
|
||||||
Extension.builder().alias("os-volumes").name("Volumes")
|
Extension.builder().alias("os-volumes").name("Volumes").namespace(URI.create("http://docs.openstack.org/ext/volumes/api/v1.1"))
|
||||||
.namespace(URI.create("http://docs.openstack.org/ext/volumes/api/v1.1"))
|
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-03-25T00:00:00+00:00")).description("Volumes support")
|
||||||
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-03-25T00:00:00+00:00"))
|
.links(Link.builder().relation(Link.Relation.SELF).href(URI.create("http://docs.openstack.org/ext/volumes/api/v1.1")).build())
|
||||||
.description("Volumes support").build(),
|
.build(),
|
||||||
Extension.builder().alias("security_groups").name("SecurityGroups")
|
Extension.builder().alias("security_groups").name("SecurityGroups")
|
||||||
.namespace(URI.create("http://docs.openstack.org/ext/securitygroups/api/v1.1"))
|
.namespace(URI.create("http://docs.openstack.org/ext/securitygroups/api/v1.1"))
|
||||||
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-07-21T00:00:00+00:00"))
|
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-07-21T00:00:00+00:00"))
|
||||||
.description("Security group support").build(),
|
.description("Security group support")
|
||||||
|
.links(Link.builder().relation(Link.Relation.SELF).href(URI.create("http://docs.openstack.org/ext/securitygroups/api/v1.1")).build())
|
||||||
|
.build(),
|
||||||
Extension.builder().alias("os-floating-ips").name("Floating_ips")
|
Extension.builder().alias("os-floating-ips").name("Floating_ips")
|
||||||
.namespace(URI.create("http://docs.openstack.org/ext/floating_ips/api/v1.1"))
|
.namespace(URI.create("http://docs.openstack.org/ext/floating_ips/api/v1.1"))
|
||||||
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-06-16T00:00:00+00:00"))
|
.updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-06-16T00:00:00+00:00")).description("Floating IPs support")
|
||||||
.description("Floating IPs support").build());
|
.links(Link.builder().relation(Link.Relation.SELF).href(URI.create("http://docs.openstack.org/ext/floating_ips/api/v1.1")).build())
|
||||||
|
.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Injector injector() {
|
protected Injector injector() {
|
||||||
|
|
|
@ -3,7 +3,12 @@
|
||||||
{
|
{
|
||||||
"updated": "2011-08-08T00:00:00+00:00",
|
"updated": "2011-08-08T00:00:00+00:00",
|
||||||
"name": "Keypairs",
|
"name": "Keypairs",
|
||||||
"links": [],
|
"links": [
|
||||||
|
{
|
||||||
|
"rel": "self",
|
||||||
|
"href": "http://docs.openstack.org/ext/keypairs/api/v1.1"
|
||||||
|
}
|
||||||
|
],
|
||||||
"namespace": "http://docs.openstack.org/ext/keypairs/api/v1.1",
|
"namespace": "http://docs.openstack.org/ext/keypairs/api/v1.1",
|
||||||
"alias": "os-keypairs",
|
"alias": "os-keypairs",
|
||||||
"description": "Keypair Support"
|
"description": "Keypair Support"
|
||||||
|
@ -11,7 +16,12 @@
|
||||||
{
|
{
|
||||||
"updated": "2011-03-25T00:00:00+00:00",
|
"updated": "2011-03-25T00:00:00+00:00",
|
||||||
"name": "Volumes",
|
"name": "Volumes",
|
||||||
"links": [],
|
"links": [
|
||||||
|
{
|
||||||
|
"rel": "self",
|
||||||
|
"href": "http://docs.openstack.org/ext/volumes/api/v1.1"
|
||||||
|
}
|
||||||
|
],
|
||||||
"namespace": "http://docs.openstack.org/ext/volumes/api/v1.1",
|
"namespace": "http://docs.openstack.org/ext/volumes/api/v1.1",
|
||||||
"alias": "os-volumes",
|
"alias": "os-volumes",
|
||||||
"description": "Volumes support"
|
"description": "Volumes support"
|
||||||
|
@ -19,7 +29,12 @@
|
||||||
{
|
{
|
||||||
"updated": "2011-07-21T00:00:00+00:00",
|
"updated": "2011-07-21T00:00:00+00:00",
|
||||||
"name": "SecurityGroups",
|
"name": "SecurityGroups",
|
||||||
"links": [],
|
"links": [
|
||||||
|
{
|
||||||
|
"rel": "self",
|
||||||
|
"href": "http://docs.openstack.org/ext/securitygroups/api/v1.1"
|
||||||
|
}
|
||||||
|
],
|
||||||
"namespace": "http://docs.openstack.org/ext/securitygroups/api/v1.1",
|
"namespace": "http://docs.openstack.org/ext/securitygroups/api/v1.1",
|
||||||
"alias": "security_groups",
|
"alias": "security_groups",
|
||||||
"description": "Security group support"
|
"description": "Security group support"
|
||||||
|
@ -27,7 +42,12 @@
|
||||||
{
|
{
|
||||||
"updated": "2011-06-16T00:00:00+00:00",
|
"updated": "2011-06-16T00:00:00+00:00",
|
||||||
"name": "Floating_ips",
|
"name": "Floating_ips",
|
||||||
"links": [],
|
"links": [
|
||||||
|
{
|
||||||
|
"rel": "self",
|
||||||
|
"href": "http://docs.openstack.org/ext/floating_ips/api/v1.1"
|
||||||
|
}
|
||||||
|
],
|
||||||
"namespace": "http://docs.openstack.org/ext/floating_ips/api/v1.1",
|
"namespace": "http://docs.openstack.org/ext/floating_ips/api/v1.1",
|
||||||
"alias": "os-floating-ips",
|
"alias": "os-floating-ips",
|
||||||
"description": "Floating IPs support"
|
"description": "Floating IPs support"
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
"name": "128 MB Server",
|
"name": "128 MB Server",
|
||||||
"ram": 128,
|
"ram": 128,
|
||||||
"disk": 10,
|
"disk": 10,
|
||||||
"vcpus": 1,
|
"vcpus": 1
|
||||||
"links": []
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue