fix Owner typing + other domain object issues

This commit is contained in:
danikov 2012-03-06 11:03:19 +00:00
parent 7c24cab71e
commit 69568bc285
6 changed files with 74 additions and 14 deletions

View File

@ -26,7 +26,7 @@ import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlRootElement;
import com.google.common.collect.Sets;
@ -54,7 +54,7 @@ import com.google.common.collect.Sets;
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "AdminCatalog")
@XmlRootElement(name = "AdminCatalog")
public class AdminCatalog extends CatalogType<AdminCatalog> {
@SuppressWarnings("unchecked")
@ -69,14 +69,13 @@ public class AdminCatalog extends CatalogType<AdminCatalog> {
public static class Builder extends CatalogType.Builder<AdminCatalog> {
public AdminCatalog build() {
AdminCatalog adminCatalog = new AdminCatalog();
return adminCatalog;
return new AdminCatalog(href, type, links, description, tasksInProgress, id, name, owner, catalogItems, isPublished);
}
/**
* @see CatalogType#getOwner()
*/
public Builder owner(Entity owner) {
public Builder owner(Owner owner) {
super.owner(owner);
return this;
}
@ -186,7 +185,13 @@ public class AdminCatalog extends CatalogType<AdminCatalog> {
}
}
@SuppressWarnings("unused")
private AdminCatalog() {
// For JAXB
}
public AdminCatalog(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, String id,
String name, Owner owner, CatalogItems catalogItems, Boolean published) {
super(href, type, links, description, tasksInProgress, id, name, owner, catalogItems, published);
}
}

View File

@ -63,7 +63,7 @@ public class Catalog extends CatalogType<Catalog> {
/**
* @see Catalog#getOwner()
*/
public Builder owner(Entity owner) {
public Builder owner(Owner owner) {
super.owner(owner);
return this;
}
@ -175,7 +175,7 @@ public class Catalog extends CatalogType<Catalog> {
}
public Catalog(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, String id,
String name, Entity owner, CatalogItems catalogItems, Boolean published) {
String name, Owner owner, CatalogItems catalogItems, Boolean published) {
super(href, type, links, description, tasksInProgress, id, name, owner, catalogItems, published);
}

View File

@ -18,16 +18,20 @@
*/
package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.Sets;
/**
@ -85,7 +89,7 @@ public class CatalogItems {
// For JAXB and builder use
}
private CatalogItems(Collection<Reference> tasks) {
private CatalogItems(Set<Reference> catalogItems) {
this.catalogItems = catalogItems;
}
@ -98,4 +102,28 @@ public class CatalogItems {
public Set<Reference> getCatalogItems() {
return Collections.unmodifiableSet(this.catalogItems);
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
CatalogItems that = CatalogItems.class.cast(o);
return equal(this.catalogItems, that.catalogItems);
}
@Override
public int hashCode() {
return Objects.hashCode(catalogItems);
}
@Override
public String toString() {
return string().toString();
}
protected ToStringHelper string() {
return Objects.toStringHelper("").add("catalogItems", catalogItems);
}
}

View File

@ -52,14 +52,14 @@ public class CatalogType<T extends CatalogType<T>> extends EntityType<T> {
public static class Builder<T extends CatalogType<T>> extends EntityType.Builder<T> {
protected Entity owner;
protected Owner owner;
protected CatalogItems catalogItems;
protected Boolean isPublished;
/**
* @see CatalogType#getOwner()
*/
public Builder<T> owner(Entity owner) {
public Builder<T> owner(Owner owner) {
this.owner = owner;
return this;
}
@ -177,7 +177,7 @@ public class CatalogType<T extends CatalogType<T>> extends EntityType<T> {
}
public CatalogType(URI href, String type, Set<Link> links, String description, TasksInProgress tasksInProgress, String id,
String name, Entity owner, CatalogItems catalogItems, Boolean published) {
String name, Owner owner, CatalogItems catalogItems, Boolean published) {
super(href, type, links, description, tasksInProgress, id, name);
this.owner = owner;
this.catalogItems = catalogItems;
@ -189,7 +189,7 @@ public class CatalogType<T extends CatalogType<T>> extends EntityType<T> {
}
@XmlElement(name = "Owner")
private Entity owner;
private Owner owner;
@XmlElement(name = "CatalogItems")
private CatalogItems catalogItems;
@XmlElement(name = "IsPublished")
@ -198,7 +198,7 @@ public class CatalogType<T extends CatalogType<T>> extends EntityType<T> {
/**
* Gets the value of the owner property.
*/
public Entity getOwner() {
public Owner getOwner() {
return owner;
}

View File

@ -18,6 +18,7 @@
*/
package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collection;
@ -27,6 +28,8 @@ import javax.xml.bind.annotation.XmlRootElement;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
@ -98,5 +101,28 @@ public class CatalogsList {
public Set<Reference> getCatalogItems() {
return this.catalogReferences;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
CatalogsList that = CatalogsList.class.cast(o);
return equal(this.catalogReferences, that.catalogReferences);
}
@Override
public int hashCode() {
return Objects.hashCode(catalogReferences);
}
@Override
public String toString() {
return string().toString();
}
protected ToStringHelper string() {
return Objects.toStringHelper("").add("catalogReferences", catalogReferences);
}
}

View File

@ -24,6 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Set;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@ -59,7 +60,6 @@ public class Owner
extends ResourceType<Owner>
{
@SuppressWarnings("unchecked")
public static Builder builder() {
return new Builder();
}
@ -134,6 +134,7 @@ public class Owner
}
}
@SuppressWarnings("unused")
private Owner() {
// For JAXB and builder use
}