mirror of https://github.com/apache/jclouds.git
Issue 695: Refactoring1: Pushed up links, actions to BaseResource as lots of duplication. Added some getAttributes overrides in builders
This commit is contained in:
parent
115f93a7d7
commit
22a63f7177
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.tmrk.enterprisecloud.domain;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
|
@ -27,6 +28,7 @@ import javax.xml.bind.annotation.XmlEnum;
|
|||
import javax.xml.bind.annotation.XmlEnumValue;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.CaseFormat.LOWER_CAMEL;
|
||||
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
|
||||
|
@ -155,6 +157,22 @@ public class Action extends BaseNamedResource<Action> {
|
|||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
throw new UnsupportedOperationException("links is not valid for Action");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
throw new UnsupportedOperationException("actions is not valid for Action");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -171,14 +189,15 @@ public class Action extends BaseNamedResource<Action> {
|
|||
@XmlAttribute
|
||||
protected ActionDisabled actionDisabled;
|
||||
|
||||
public Action(URI href, String type, String name, @Nullable ActionDisabled actionDisabled) {
|
||||
super(href, type, name);
|
||||
private Action(URI href, String type, String name, @Nullable ActionDisabled actionDisabled) {
|
||||
super(href, type, Sets.<Link>newLinkedHashSet(), Sets.<Action>newLinkedHashSet(), name);
|
||||
this.actionDisabled = actionDisabled;
|
||||
}
|
||||
|
||||
protected Action() {
|
||||
private Action() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
/**
|
||||
* The attribute actionDisabled appears only when the example has an action
|
||||
* disabled for business rules.
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.tmrk.enterprisecloud.domain;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
|
||||
|
@ -26,6 +27,7 @@ import javax.xml.bind.annotation.XmlEnum;
|
|||
import javax.xml.bind.annotation.XmlEnumValue;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
|
@ -170,6 +172,22 @@ public class Link extends BaseNamedResource<Link> {
|
|||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
throw new UnsupportedOperationException("links is not valid for Link");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
throw new UnsupportedOperationException("actions is not valid for Link");
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -185,12 +203,12 @@ public class Link extends BaseNamedResource<Link> {
|
|||
@XmlAttribute
|
||||
protected Relationship rel;
|
||||
|
||||
public Link(URI href, String type, String name, Relationship rel) {
|
||||
super(href, type, name);
|
||||
private Link(URI href, String type, String name, Relationship rel) {
|
||||
super(href, type, Sets.<Link>newLinkedHashSet(), Sets.<Action>newLinkedHashSet(), name);
|
||||
this.rel = checkNotNull(rel, "rel");
|
||||
}
|
||||
|
||||
protected Link() {
|
||||
private Link() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.jclouds.tmrk.enterprisecloud.domain;
|
|||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
|
@ -51,7 +52,7 @@ public class NamedResource extends BaseNamedResource<NamedResource> {
|
|||
*/
|
||||
@Override
|
||||
public NamedResource build() {
|
||||
return new NamedResource(href, type, name);
|
||||
return new NamedResource(href, type, links, actions, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,6 +95,22 @@ public class NamedResource extends BaseNamedResource<NamedResource> {
|
|||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -104,8 +121,8 @@ public class NamedResource extends BaseNamedResource<NamedResource> {
|
|||
|
||||
}
|
||||
|
||||
public NamedResource(URI href, String type, String name) {
|
||||
super(href, type, name);
|
||||
private NamedResource(URI href, String type, Set<Link> links, Set<Action> actions, String name) {
|
||||
super(href, type, links, actions, name);
|
||||
}
|
||||
|
||||
protected NamedResource() {
|
||||
|
|
|
@ -25,6 +25,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
|
@ -186,7 +187,7 @@ public class Task extends BaseResource<Task> {
|
|||
|
||||
@Override
|
||||
public Task build() {
|
||||
return new Task(href, type, operation, status, impactedItem, startTime, completedTime, notes, errorMessage,
|
||||
return new Task(href, type, links, actions, operation, status, impactedItem, startTime, completedTime, notes, errorMessage,
|
||||
initiatedBy);
|
||||
}
|
||||
|
||||
|
@ -220,6 +221,22 @@ public class Task extends BaseResource<Task> {
|
|||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -254,9 +271,9 @@ public class Task extends BaseResource<Task> {
|
|||
@XmlElement(name = "InitiatedBy", required = true)
|
||||
protected NamedResource initiatedBy;
|
||||
|
||||
public Task(URI href, String type, String operation, Status status, NamedResource impactedItem, Date startTime,
|
||||
private Task(URI href, String type, Set<Link> links, Set<Action> actions, String operation, Status status, NamedResource impactedItem, Date startTime,
|
||||
@Nullable Date completedTime, @Nullable String notes, @Nullable String errorMessage, NamedResource initiatedBy) {
|
||||
super(href, type);
|
||||
super(href, type, links, actions);
|
||||
this.operation = checkNotNull(operation, "operation");
|
||||
this.status = checkNotNull(status, "status");
|
||||
this.impactedItem = checkNotNull(impactedItem, "impactedItem");
|
||||
|
@ -267,7 +284,7 @@ public class Task extends BaseResource<Task> {
|
|||
this.initiatedBy = checkNotNull(initiatedBy, "initiatedBy");
|
||||
}
|
||||
|
||||
protected Task() {
|
||||
private Task() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.Sets;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Action;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Actions;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.network.Nics;
|
||||
|
@ -59,21 +59,11 @@ public class HardwareConfiguration extends BaseResource<HardwareConfiguration> {
|
|||
|
||||
public static class Builder extends BaseResource.Builder<HardwareConfiguration> {
|
||||
|
||||
// TODO Links
|
||||
private Set<Action> actions = Sets.newLinkedHashSet();
|
||||
private int processorCount;
|
||||
private ResourceCapacity memory;
|
||||
private Set<VirtualDisk> virtualDisks = Sets.newLinkedHashSet();
|
||||
private Set<VirtualNic> virtualNics = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see HardwareConfiguration#getActions
|
||||
*/
|
||||
public Builder actions(Set<Action> actions) {
|
||||
this.actions = ImmutableSet.<Action> copyOf(checkNotNull(actions, "actions"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HardwareConfiguration#getProcessorCount
|
||||
*/
|
||||
|
@ -109,7 +99,7 @@ public class HardwareConfiguration extends BaseResource<HardwareConfiguration> {
|
|||
|
||||
@Override
|
||||
public HardwareConfiguration build() {
|
||||
return new HardwareConfiguration(actions, processorCount, memory, virtualDisks, virtualNics);
|
||||
return new HardwareConfiguration(processorCount, memory, virtualDisks, virtualNics);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -136,6 +126,22 @@ public class HardwareConfiguration extends BaseResource<HardwareConfiguration> {
|
|||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -145,17 +151,13 @@ public class HardwareConfiguration extends BaseResource<HardwareConfiguration> {
|
|||
}
|
||||
|
||||
public Builder fromHardwareConfiguration(HardwareConfiguration in) {
|
||||
return fromResource(in).actions(in.getActions())
|
||||
.processorCount(in.getProcessorCount())
|
||||
return fromResource(in).processorCount(in.getProcessorCount())
|
||||
.memory(in.getMemory())
|
||||
.disks(in.getVirtualDisks())
|
||||
.nics(in.getVirtualNics());
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "Actions", required = false)
|
||||
private Actions actions = Actions.builder().build();
|
||||
|
||||
@XmlElement(name = "ProcessorCount", required = true)
|
||||
private int processorCount;
|
||||
|
||||
|
@ -168,22 +170,17 @@ public class HardwareConfiguration extends BaseResource<HardwareConfiguration> {
|
|||
@XmlElement(name = "Nics", required = false)
|
||||
private Nics virtualNics = Nics.builder().build();
|
||||
|
||||
public HardwareConfiguration(Set<Action> actions, int processorCount, @Nullable ResourceCapacity memory, Set<VirtualDisk> virtualDisks, Set<VirtualNic> virtualNics) {
|
||||
this.actions = Actions.builder().actions(checkNotNull(actions, "actions")).build();
|
||||
private HardwareConfiguration(int processorCount, @Nullable ResourceCapacity memory, Set<VirtualDisk> virtualDisks, Set<VirtualNic> virtualNics) {
|
||||
this.virtualDisks = Disks.builder().disks(checkNotNull(virtualDisks,"virtualDisks")).build();
|
||||
this.virtualNics = Nics.builder().nics(checkNotNull(virtualNics, "virtualNics")).build();
|
||||
this.processorCount = processorCount;
|
||||
this.memory = memory;
|
||||
}
|
||||
|
||||
protected HardwareConfiguration() {
|
||||
private HardwareConfiguration() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
public Set<Action> getActions() {
|
||||
return Collections.unmodifiableSet(actions.getActions());
|
||||
}
|
||||
|
||||
public int getProcessorCount() {
|
||||
return processorCount;
|
||||
}
|
||||
|
@ -209,7 +206,6 @@ public class HardwareConfiguration extends BaseResource<HardwareConfiguration> {
|
|||
HardwareConfiguration that = (HardwareConfiguration) o;
|
||||
|
||||
if (processorCount != that.processorCount) return false;
|
||||
if (!actions.equals(that.actions)) return false;
|
||||
if (!virtualDisks.equals(that.virtualDisks)) return false;
|
||||
if (memory != null ? !memory.equals(that.memory) : that.memory != null)
|
||||
return false;
|
||||
|
@ -221,7 +217,6 @@ public class HardwareConfiguration extends BaseResource<HardwareConfiguration> {
|
|||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + actions.hashCode();
|
||||
result = 31 * result + processorCount;
|
||||
result = 31 * result + (memory != null ? memory.hashCode() : 0);
|
||||
result = 31 * result + virtualDisks.hashCode();
|
||||
|
@ -231,7 +226,7 @@ public class HardwareConfiguration extends BaseResource<HardwareConfiguration> {
|
|||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", actions="+actions+", processorCount="+processorCount+
|
||||
return super.string()+", processorCount="+processorCount+
|
||||
", memory="+memory+", disks="+ virtualDisks +", nics="+ virtualNics;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,12 +18,16 @@
|
|||
*/
|
||||
package org.jclouds.tmrk.enterprisecloud.domain.internal;
|
||||
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Action;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Location of a Rest resource
|
||||
|
@ -54,7 +58,7 @@ public class BaseNamedResource<T extends BaseNamedResource<T>> extends BaseResou
|
|||
}
|
||||
|
||||
public BaseNamedResource<T> build() {
|
||||
return new BaseNamedResource<T>(href, type, name);
|
||||
return new BaseNamedResource<T>(href, type, links, actions, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,8 +86,8 @@ public class BaseNamedResource<T extends BaseNamedResource<T>> extends BaseResou
|
|||
@XmlAttribute
|
||||
protected String name;
|
||||
|
||||
public BaseNamedResource(URI href, String type, String name) {
|
||||
super(href, type);
|
||||
protected BaseNamedResource(URI href, String type, Set<Link> links, Set<Action> actions, String name) {
|
||||
super(href, type, links, actions);
|
||||
this.name = checkNotNull(name, "name");
|
||||
}
|
||||
|
||||
|
|
|
@ -18,12 +18,21 @@
|
|||
*/
|
||||
package org.jclouds.tmrk.enterprisecloud.domain.internal;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Action;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Actions;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Links;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Location of a Rest resource
|
||||
|
@ -45,6 +54,8 @@ public class BaseResource<T extends BaseResource<T>> {
|
|||
|
||||
protected String type;
|
||||
protected URI href;
|
||||
protected Set<Link> links = Sets.newLinkedHashSet();
|
||||
protected Set<Action> actions = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see BaseResource#getType
|
||||
|
@ -62,12 +73,28 @@ public class BaseResource<T extends BaseResource<T>> {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see BaseResource#getLinks
|
||||
*/
|
||||
public Builder links(Set<Link> links) {
|
||||
this.links = ImmutableSet.<Link> copyOf(checkNotNull(links, "links"));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see BaseResource#getActions
|
||||
*/
|
||||
public Builder actions(Set<Action> actions) {
|
||||
this.actions = ImmutableSet.<Action> copyOf(checkNotNull(actions, "actions"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public BaseResource<T> build() {
|
||||
return new BaseResource<T>(href, type);
|
||||
return new BaseResource<T>(href, type, links, actions);
|
||||
}
|
||||
|
||||
public Builder<T> fromResource(BaseResource<T> in) {
|
||||
return type(in.getType()).href(in.getHref());
|
||||
return type(in.getType()).href(in.getHref()).links(in.getLinks()).actions(in.getActions());
|
||||
}
|
||||
|
||||
public Builder<T> fromAttributes(Map<String, String> attributes) {
|
||||
|
@ -82,9 +109,17 @@ public class BaseResource<T extends BaseResource<T>> {
|
|||
@XmlAttribute
|
||||
protected URI href;
|
||||
|
||||
public BaseResource(URI href, String type) {
|
||||
@XmlElement(name = "Links", required = false)
|
||||
protected Links links = Links.builder().build();
|
||||
|
||||
@XmlElement(name = "Actions", required = false)
|
||||
protected Actions actions = Actions.builder().build();
|
||||
|
||||
public BaseResource(URI href, String type, Set<Link> links, Set<Action> actions) {
|
||||
this.type = checkNotNull(type, "type");
|
||||
this.href = checkNotNull(href, "href");
|
||||
this.links = Links.builder().links(checkNotNull(links,"links")).build();
|
||||
this.actions = Actions.builder().actions(checkNotNull(actions, "actions")).build();
|
||||
}
|
||||
|
||||
protected BaseResource() {
|
||||
|
@ -107,43 +142,54 @@ public class BaseResource<T extends BaseResource<T>> {
|
|||
return href;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((href == null) ? 0 : href.hashCode());
|
||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
||||
return result;
|
||||
/**
|
||||
* @return the links related to this object
|
||||
*/
|
||||
public Set<Link> getLinks() {
|
||||
return links.getLinks();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the actions available from this object
|
||||
*/
|
||||
public Set<Action> getActions() {
|
||||
return actions.getActions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
BaseResource that = (BaseResource) o;
|
||||
|
||||
if (actions != null ? !actions.equals(that.actions) : that.actions != null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
if (href != null ? !href.equals(that.href) : that.href != null)
|
||||
return false;
|
||||
BaseResource<?> other = (BaseResource<?>) obj;
|
||||
if (href == null) {
|
||||
if (other.href != null)
|
||||
return false;
|
||||
} else if (!href.equals(other.href))
|
||||
if (links != null ? !links.equals(that.links) : that.links != null)
|
||||
return false;
|
||||
if (type == null) {
|
||||
if (other.type != null)
|
||||
return false;
|
||||
} else if (!type.equals(other.type))
|
||||
if (type != null ? !type.equals(that.type) : that.type != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = type != null ? type.hashCode() : 0;
|
||||
result = 31 * result + (href != null ? href.hashCode() : 0);
|
||||
result = 31 * result + (links != null ? links.hashCode() : 0);
|
||||
result = 31 * result + (actions != null ? actions.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[%s]",string());
|
||||
}
|
||||
|
||||
protected String string() {
|
||||
return "href="+href+", type="+type;
|
||||
return "href="+href+", type="+type+", links="+links+", actions="+actions;
|
||||
}
|
||||
}
|
|
@ -18,7 +18,9 @@
|
|||
*/
|
||||
package org.jclouds.tmrk.enterprisecloud.domain.network;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Actions;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
@ -34,17 +36,11 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
@XmlRootElement(name="AssignedIpAddresses")
|
||||
public class AssignedIpAddresses extends BaseResource<AssignedIpAddresses> {
|
||||
|
||||
//TODO links
|
||||
|
||||
@XmlElement(name = "Actions", required = true)
|
||||
private Actions actions = Actions.builder().build();
|
||||
|
||||
@XmlElement(name = "Networks", required = true)
|
||||
private DeviceNetworks networks = new DeviceNetworks();
|
||||
|
||||
public AssignedIpAddresses(URI href, String type, Actions actions, DeviceNetworks networks) {
|
||||
super(href, type);
|
||||
checkNotNull(actions,"actions");
|
||||
super(href, type, Sets.<Link>newIdentityHashSet(), actions.getActions());
|
||||
checkNotNull(networks,"networks");
|
||||
}
|
||||
|
||||
|
@ -52,10 +48,6 @@ public class AssignedIpAddresses extends BaseResource<AssignedIpAddresses> {
|
|||
//For JAXB
|
||||
}
|
||||
|
||||
public Actions getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
public DeviceNetworks getNetworks() {
|
||||
return networks;
|
||||
}
|
||||
|
@ -68,7 +60,6 @@ public class AssignedIpAddresses extends BaseResource<AssignedIpAddresses> {
|
|||
|
||||
AssignedIpAddresses that = (AssignedIpAddresses) o;
|
||||
|
||||
if (!actions.equals(that.actions)) return false;
|
||||
if (!networks.equals(that.networks)) return false;
|
||||
|
||||
return true;
|
||||
|
@ -77,14 +68,13 @@ public class AssignedIpAddresses extends BaseResource<AssignedIpAddresses> {
|
|||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + actions.hashCode();
|
||||
result = 31 * result + networks.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", actions="+actions+", networks="+networks;
|
||||
return super.string()+", networks="+networks;
|
||||
}
|
||||
|
||||
}
|
|
@ -32,7 +32,7 @@ public class DeviceNetwork extends BaseNamedResource<DeviceNetwork> {
|
|||
@XmlElement(name = "IpAddresses")
|
||||
private DeviceIps ipAddresses = new DeviceIps();
|
||||
|
||||
protected DeviceNetwork() {
|
||||
private DeviceNetwork() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
package org.jclouds.tmrk.enterprisecloud.domain.network;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Action;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
|
||||
|
@ -26,6 +28,8 @@ import javax.xml.bind.annotation.XmlElement;
|
|||
import javax.xml.bind.annotation.XmlEnum;
|
||||
import javax.xml.bind.annotation.XmlEnumValue;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.CaseFormat.LOWER_CAMEL;
|
||||
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
|
||||
|
@ -82,7 +86,7 @@ public class NetworkReference extends BaseNamedResource<NetworkReference> {
|
|||
|
||||
@Override
|
||||
public NetworkReference build() {
|
||||
return new NetworkReference(href, type, name, networkType);
|
||||
return new NetworkReference(href, type, links, actions, name, networkType);
|
||||
}
|
||||
|
||||
public Builder fromNetworkReference(NetworkReference in) {
|
||||
|
@ -128,17 +132,41 @@ public class NetworkReference extends BaseNamedResource<NetworkReference> {
|
|||
public Builder type(String type) {
|
||||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromAttributes(Map<String, String> attributes) {
|
||||
return Builder.class.cast(super.fromAttributes(attributes));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "NetworkType")
|
||||
private NetworkType networkType;
|
||||
|
||||
public NetworkReference(URI href, String type, String name,@Nullable NetworkType networkType) {
|
||||
super(href, type, name);
|
||||
private NetworkReference(URI href, String type, Set<Link> links, Set<Action> actions, String name,@Nullable NetworkType networkType) {
|
||||
super(href, type, links, actions, name);
|
||||
this.networkType = networkType;
|
||||
}
|
||||
|
||||
protected NetworkReference() {
|
||||
private NetworkReference() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
|
|
|
@ -18,11 +18,14 @@
|
|||
*/
|
||||
package org.jclouds.tmrk.enterprisecloud.domain.software;
|
||||
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Action;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <xs:complexType name="OperatingSystem">
|
||||
|
@ -53,7 +56,7 @@ public class OperatingSystem extends BaseNamedResource<OperatingSystem> {
|
|||
*/
|
||||
@Override
|
||||
public OperatingSystem build() {
|
||||
return new OperatingSystem(href, type, name);
|
||||
return new OperatingSystem(href, type, links, actions, name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,6 +99,22 @@ public class OperatingSystem extends BaseNamedResource<OperatingSystem> {
|
|||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -106,11 +125,11 @@ public class OperatingSystem extends BaseNamedResource<OperatingSystem> {
|
|||
|
||||
}
|
||||
|
||||
public OperatingSystem(URI href, String type, String name) {
|
||||
super(href, type, name);
|
||||
private OperatingSystem(URI href, String type, Set<Link> links, Set<Action> actions, String name) {
|
||||
super(href, type, links, actions, name);
|
||||
}
|
||||
|
||||
protected OperatingSystem() {
|
||||
private OperatingSystem() {
|
||||
//For JAXB
|
||||
}
|
||||
}
|
|
@ -19,10 +19,7 @@
|
|||
package org.jclouds.tmrk.enterprisecloud.domain.template;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.ConfigurationOptionRange;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.CustomizationOption;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Links;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.ResourceCapacityRange;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.*;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.software.OperatingSystem;
|
||||
|
@ -30,6 +27,8 @@ import org.jclouds.tmrk.enterprisecloud.domain.software.OperatingSystem;
|
|||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <xs:complexType name="Template">
|
||||
|
@ -54,7 +53,6 @@ public class Template extends BaseNamedResource<Template> {
|
|||
|
||||
public static class Builder extends BaseNamedResource.Builder<Template> {
|
||||
//TODO There are additional fields
|
||||
protected Links links;
|
||||
protected OperatingSystem operatingSystem;
|
||||
protected String description;
|
||||
//protected ComputeMatrix computeMatrix;
|
||||
|
@ -65,14 +63,6 @@ public class Template extends BaseNamedResource<Template> {
|
|||
protected CustomizationOption customization;
|
||||
//protected DeviceLicensedSoftware licensedSoftware;
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.template.Template#getLinks
|
||||
*/
|
||||
public Builder links(Links links) {
|
||||
this.links = links;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.template.Template#getOperatingSystem
|
||||
*/
|
||||
|
@ -131,7 +121,7 @@ public class Template extends BaseNamedResource<Template> {
|
|||
|
||||
@Override
|
||||
public Template build() {
|
||||
return new Template(href, type, name, links, operatingSystem, description, processor, memory, storage, networkAdapters, customization);
|
||||
return new Template(href, type, links, actions, name, operatingSystem, description, processor, memory, storage, networkAdapters, customization);
|
||||
}
|
||||
|
||||
public Builder fromTask(Template in) {
|
||||
|
@ -162,6 +152,22 @@ public class Template extends BaseNamedResource<Template> {
|
|||
return Builder.class.cast(super.type(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -169,10 +175,15 @@ public class Template extends BaseNamedResource<Template> {
|
|||
public Builder href(URI href) {
|
||||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "Links", required = false)
|
||||
protected Links links;
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromAttributes(Map<String, String> attributes) {
|
||||
return Builder.class.cast(super.fromAttributes(attributes));
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "OperatingSystem", required = false)
|
||||
protected OperatingSystem operatingSystem;
|
||||
|
@ -199,11 +210,10 @@ public class Template extends BaseNamedResource<Template> {
|
|||
|
||||
//protected DeviceLicensedSoftware licensedSoftware;
|
||||
|
||||
private Template(URI href, String type, String name, @Nullable Links links, @Nullable OperatingSystem operatingSystem, @Nullable String description,
|
||||
private Template(URI href, String type, Set<Link> links, Set<Action> actions, String name, @Nullable OperatingSystem operatingSystem, @Nullable String description,
|
||||
@Nullable ConfigurationOptionRange processor, @Nullable ResourceCapacityRange memory,
|
||||
@Nullable TemplateStorage storage, @Nullable int networkAdapters, @Nullable CustomizationOption customization) {
|
||||
super(href, type, name);
|
||||
this.links = links;
|
||||
super(href, type, links, actions, name);
|
||||
this.operatingSystem = operatingSystem;
|
||||
this.description = description;
|
||||
this.processor = processor;
|
||||
|
@ -217,10 +227,6 @@ public class Template extends BaseNamedResource<Template> {
|
|||
//For JAXB
|
||||
}
|
||||
|
||||
public Links getLinks() {
|
||||
return links;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
@ -262,8 +268,6 @@ public class Template extends BaseNamedResource<Template> {
|
|||
return false;
|
||||
if (description != null ? !description.equals(template.description) : template.description != null)
|
||||
return false;
|
||||
if (links != null ? !links.equals(template.links) : template.links != null)
|
||||
return false;
|
||||
if (memory != null ? !memory.equals(template.memory) : template.memory != null)
|
||||
return false;
|
||||
if (operatingSystem != null ? !operatingSystem.equals(template.operatingSystem) : template.operatingSystem != null)
|
||||
|
@ -279,7 +283,6 @@ public class Template extends BaseNamedResource<Template> {
|
|||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (links != null ? links.hashCode() : 0);
|
||||
result = 31 * result + (operatingSystem != null ? operatingSystem.hashCode() : 0);
|
||||
result = 31 * result + (description != null ? description.hashCode() : 0);
|
||||
result = 31 * result + (processor != null ? processor.hashCode() : 0);
|
||||
|
@ -292,7 +295,7 @@ public class Template extends BaseNamedResource<Template> {
|
|||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", links="+ links+", operatingSystem="+ operatingSystem+
|
||||
return super.string()+", operatingSystem="+ operatingSystem+
|
||||
", description="+ description+", processor="+ processor+
|
||||
", memory="+ memory+", storage="+ storage+
|
||||
", networkAdapters="+ networkAdapters+", customization="+ customization;
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.jclouds.tmrk.enterprisecloud.domain.template;
|
|||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.NamedResource;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.util.Set;
|
||||
|
@ -44,12 +45,12 @@ public class TemplateOperatingSystem {
|
|||
public static class Builder {
|
||||
|
||||
private String name;
|
||||
private Set<TemplateReference> templates = Sets.newLinkedHashSet();
|
||||
private Set<NamedResource> templates = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see TemplateOperatingSystem#getTemplates
|
||||
*/
|
||||
public Builder templates(Set<TemplateReference> templates) {
|
||||
public Builder templates(Set<NamedResource> templates) {
|
||||
this.templates = Sets.newLinkedHashSet(checkNotNull(templates, "templates"));
|
||||
return this;
|
||||
}
|
||||
|
@ -77,7 +78,7 @@ public class TemplateOperatingSystem {
|
|||
@XmlElement(name = "Templates", required = false)
|
||||
private TemplateReferences templates = TemplateReferences.builder().build();
|
||||
|
||||
private TemplateOperatingSystem(@Nullable String name, Set<TemplateReference> templates) {
|
||||
private TemplateOperatingSystem(@Nullable String name, Set<NamedResource> templates) {
|
||||
this.name = name;
|
||||
this.templates = TemplateReferences.builder().templateReferences(checkNotNull(templates,"templates")).build();
|
||||
}
|
||||
|
@ -91,7 +92,7 @@ public class TemplateOperatingSystem {
|
|||
return name;
|
||||
}
|
||||
|
||||
public Set<TemplateReference> getTemplates() {
|
||||
public Set<NamedResource> getTemplates() {
|
||||
return templates.getTemplateReferences();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.tmrk.enterprisecloud.domain.template;
|
||||
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseNamedResource;
|
||||
|
||||
/**
|
||||
* @author Jason King
|
||||
*/
|
||||
public class TemplateReference extends BaseNamedResource<TemplateReference> {
|
||||
public TemplateReference() {
|
||||
//For JAXB
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@
|
|||
package org.jclouds.tmrk.enterprisecloud.domain.template;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.NamedResource;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import java.util.Collections;
|
||||
|
@ -45,17 +46,17 @@ public class TemplateReferences {
|
|||
|
||||
public static class Builder {
|
||||
|
||||
private Set<TemplateReference> templateReferences = Sets.newLinkedHashSet();
|
||||
private Set<NamedResource> templateReferences = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see org.jclouds.tmrk.enterprisecloud.domain.template.TemplateReferences#getTemplateReferences()
|
||||
*/
|
||||
public Builder templateReferences(Set<TemplateReference> templateReferences) {
|
||||
public Builder templateReferences(Set<NamedResource> templateReferences) {
|
||||
this.templateReferences = Sets.newLinkedHashSet(checkNotNull(templateReferences, "templateReferences"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addTemplateReference(TemplateReference templateReference) {
|
||||
public Builder addTemplateReference(NamedResource templateReference) {
|
||||
templateReferences.add(checkNotNull(templateReference,"templateReference"));
|
||||
return this;
|
||||
}
|
||||
|
@ -73,14 +74,14 @@ public class TemplateReferences {
|
|||
//For JAXB and builder use
|
||||
}
|
||||
|
||||
private TemplateReferences(Set<TemplateReference> templateReferences) {
|
||||
private TemplateReferences(Set<NamedResource> templateReferences) {
|
||||
this.templateReferences = Sets.newLinkedHashSet(templateReferences);
|
||||
}
|
||||
|
||||
@XmlElement(name = "Template")
|
||||
private Set<TemplateReference> templateReferences = Sets.newLinkedHashSet();
|
||||
private Set<NamedResource> templateReferences = Sets.newLinkedHashSet();
|
||||
|
||||
public Set<TemplateReference> getTemplateReferences() {
|
||||
public Set<NamedResource> getTemplateReferences() {
|
||||
return Collections.unmodifiableSet(templateReferences);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
package org.jclouds.tmrk.enterprisecloud.domain.template;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Action;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Link;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.Links;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
@ -56,17 +56,8 @@ public class Templates extends BaseResource<Templates> {
|
|||
}
|
||||
|
||||
public static class Builder extends BaseResource.Builder<Templates> {
|
||||
private Links links = Links.builder().build();
|
||||
private Set<TemplateFamily> families = Sets.newLinkedHashSet();
|
||||
|
||||
/**
|
||||
* @see Templates#getLinks
|
||||
*/
|
||||
public Builder links(Set<Link> links) {
|
||||
this.links = Links.builder().links(checkNotNull(links,"links")).build();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Templates#getTemplateFamilies
|
||||
*/
|
||||
|
@ -77,11 +68,11 @@ public class Templates extends BaseResource<Templates> {
|
|||
|
||||
@Override
|
||||
public Templates build() {
|
||||
return new Templates(href, type, links, families);
|
||||
return new Templates(href, type, links, actions, families);
|
||||
}
|
||||
|
||||
public Builder fromTemplates(Templates in) {
|
||||
return fromResource(in).links(in.getLinks()).families(in.getTemplateFamilies());
|
||||
return fromResource(in).families(in.getTemplateFamilies());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,6 +99,22 @@ public class Templates extends BaseResource<Templates> {
|
|||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -118,15 +125,11 @@ public class Templates extends BaseResource<Templates> {
|
|||
|
||||
}
|
||||
|
||||
@XmlElement(name = "Links", required = false)
|
||||
private Links links = Links.builder().build();
|
||||
|
||||
@XmlElement(name = "Families", required = false)
|
||||
private TemplateFamilies families;
|
||||
|
||||
private Templates(URI href, String type, Links links, Set<TemplateFamily> families) {
|
||||
super(href, type);
|
||||
this.links = checkNotNull(links, "links");
|
||||
private Templates(URI href, String type, Set<Link> links, Set<Action> actions, Set<TemplateFamily> families) {
|
||||
super(href, type, links, actions);
|
||||
this.families = TemplateFamilies.builder().families(families).build();
|
||||
}
|
||||
|
||||
|
@ -152,8 +155,6 @@ public class Templates extends BaseResource<Templates> {
|
|||
|
||||
if (families != null ? !families.equals(templates.families) : templates.families != null)
|
||||
return false;
|
||||
if (links != null ? !links.equals(templates.links) : templates.links != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -161,13 +162,12 @@ public class Templates extends BaseResource<Templates> {
|
|||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (links != null ? links.hashCode() : 0);
|
||||
result = 31 * result + (families != null ? families.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", links="+links+", families="+families;
|
||||
return super.string()+", families="+families;
|
||||
}
|
||||
}
|
|
@ -62,8 +62,6 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
|
||||
public static class Builder extends BaseNamedResource.Builder<VirtualMachine> {
|
||||
//TODO There are some more fields
|
||||
private Links links = Links.builder().build();
|
||||
private Actions actions = Actions.builder().build();
|
||||
private Tasks tasks = Tasks.builder().build();
|
||||
private String description;
|
||||
private VirtualMachineStatus status;
|
||||
|
@ -77,23 +75,6 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
private HardwareConfiguration hardwareConfiguration;
|
||||
private VirtualMachineIpAddresses ipAddresses = new VirtualMachineIpAddresses();
|
||||
|
||||
/**
|
||||
* @see VirtualMachine#getLinks
|
||||
*/
|
||||
public Builder links(Set<Link> links) {
|
||||
this.links = Links.builder().links(checkNotNull(links,"links")).build();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualMachine#getActions
|
||||
*/
|
||||
public Builder actions(Set<Action> actions) {
|
||||
checkNotNull(actions,"actions");
|
||||
this.actions = Actions.builder().actions(actions).build();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see VirtualMachine#getTasks
|
||||
*/
|
||||
|
@ -199,9 +180,7 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
|
||||
public Builder fromVirtualMachine(VirtualMachine in) {
|
||||
return fromNamedResource(in)
|
||||
.links(in.getLinks())
|
||||
.tasks(in.getTasks())
|
||||
.actions(in.getActions())
|
||||
.description(in.getDescription())
|
||||
.layout(in.getLayout())
|
||||
.status(in.getStatus())
|
||||
|
@ -246,6 +225,22 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -259,21 +254,17 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
*/
|
||||
@Override
|
||||
public Builder fromAttributes(Map<String, String> attributes) {
|
||||
return Builder.class.cast(super.fromAttributes(attributes));
|
||||
// TODO Other fields?
|
||||
super.fromAttributes(attributes);
|
||||
if (attributes.containsKey("description"))
|
||||
description(attributes.get("description"));
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@XmlElement(name = "Links", required = true)
|
||||
private Links links = Links.builder().build();
|
||||
|
||||
@XmlElement(name = "Tasks", required = true)
|
||||
private Tasks tasks = Tasks.builder().build();
|
||||
|
||||
@XmlElement(name = "Actions", required = true)
|
||||
private Actions actions = Actions.builder().build();
|
||||
|
||||
@XmlElement(name = "Description", required = true)
|
||||
private String description;
|
||||
|
||||
|
@ -304,14 +295,12 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
@XmlElement(name = "IpAddresses", required = false)
|
||||
private VirtualMachineIpAddresses ipAddresses = new VirtualMachineIpAddresses();
|
||||
|
||||
public VirtualMachine(URI href, String type, String name, Tasks tasks, Actions actions, Links links, String description, @Nullable Layout layout,
|
||||
private VirtualMachine(URI href, String type, String name, Tasks tasks, Set<Action> actions, Set<Link> links, String description, @Nullable Layout layout,
|
||||
VirtualMachineStatus status, boolean poweredOn, @Nullable ToolsStatus toolsStatus, @Nullable VirtualMachineMediaStatus mediaStatus, boolean customizationPending,
|
||||
@Nullable OperatingSystem operatingSystem, @Nullable HardwareConfiguration hardwareConfiguration, @Nullable VirtualMachineIpAddresses ipAddresses) {
|
||||
super(href, type, name);
|
||||
super(href, type, links, actions, name);
|
||||
this.description = checkNotNull(description, "description");
|
||||
this.links = checkNotNull(links, "links");
|
||||
this.tasks = checkNotNull(tasks, "tasks");
|
||||
this.actions = checkNotNull(actions, "actions");
|
||||
this.status = checkNotNull(status, "status");
|
||||
this.ipAddresses = checkNotNull(ipAddresses, "ipAddresses");
|
||||
|
||||
|
@ -324,29 +313,20 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
this.hardwareConfiguation = hardwareConfiguration;
|
||||
}
|
||||
|
||||
protected VirtualMachine() {
|
||||
private VirtualMachine() {
|
||||
//For JAXB
|
||||
}
|
||||
|
||||
|
||||
public Set<Link> getLinks() {
|
||||
return Collections.unmodifiableSet(links.getLinks());
|
||||
}
|
||||
|
||||
/**
|
||||
* refers to tasks regarding the virtual machine.
|
||||
* Only the most recent tasks, up to twenty, are returned.
|
||||
* Use the href to retrieve the complete list of tasks.
|
||||
* @return most recent tasks
|
||||
*/
|
||||
/**
|
||||
* refers to tasks regarding the virtual machine.
|
||||
* Only the most recent tasks, up to twenty, are returned.
|
||||
* Use the href to retrieve the complete list of tasks.
|
||||
* @return most recent tasks
|
||||
*/
|
||||
public Set<Task> getTasks() {
|
||||
return Collections.unmodifiableSet(tasks.getTasks());
|
||||
}
|
||||
|
||||
public Set<Action> getActions() {
|
||||
return Collections.unmodifiableSet(actions.getActions());
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
@ -409,7 +389,6 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
|
||||
if (customizationPending != that.customizationPending) return false;
|
||||
if (poweredOn != that.poweredOn) return false;
|
||||
if (!actions.equals(that.actions)) return false;
|
||||
if (description != null ? !description.equals(that.description) : that.description != null)
|
||||
return false;
|
||||
if (hardwareConfiguation != null ? !hardwareConfiguation.equals(that.hardwareConfiguation) : that.hardwareConfiguation != null)
|
||||
|
@ -417,7 +396,6 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
if (!ipAddresses.equals(that.ipAddresses)) return false;
|
||||
if (layout != null ? !layout.equals(that.layout) : that.layout != null)
|
||||
return false;
|
||||
if (!links.equals(that.links)) return false;
|
||||
if (mediaStatus != that.mediaStatus) return false;
|
||||
if (operatingSystem != null ? !operatingSystem.equals(that.operatingSystem) : that.operatingSystem != null)
|
||||
return false;
|
||||
|
@ -431,9 +409,7 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + links.hashCode();
|
||||
result = 31 * result + tasks.hashCode();
|
||||
result = 31 * result + actions.hashCode();
|
||||
result = 31 * result + (description != null ? description.hashCode() : 0);
|
||||
result = 31 * result + (layout != null ? layout.hashCode() : 0);
|
||||
result = 31 * result + (status != null ? status.hashCode() : 0);
|
||||
|
@ -449,7 +425,7 @@ public class VirtualMachine extends BaseNamedResource<VirtualMachine> {
|
|||
|
||||
@Override
|
||||
public String string() {
|
||||
return super.string()+", links="+links+", tasks="+tasks+", actions="+actions+", description="+description+", layout="+layout+
|
||||
return super.string()+", tasks="+tasks+", description="+description+", layout="+layout+
|
||||
", status="+status+", poweredOn="+poweredOn+", toolsStatus="+toolsStatus+", mediaStatus="+mediaStatus+
|
||||
", customizationPending="+customizationPending+", operatingSystem="+operatingSystem+", hardwareConfiguration="+hardwareConfiguation+
|
||||
", ipAddresses="+ipAddresses;
|
||||
|
|
|
@ -26,6 +26,8 @@ import org.jclouds.tmrk.enterprisecloud.domain.internal.BaseResource;
|
|||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <xs:complexType name="VirtualMachineConfigurationOptions">
|
||||
|
@ -99,7 +101,7 @@ public class VirtualMachineConfigurationOptions extends BaseResource<VirtualMach
|
|||
|
||||
@Override
|
||||
public VirtualMachineConfigurationOptions build() {
|
||||
return new VirtualMachineConfigurationOptions(href, type, processor, memory, disk, networkAdapter, customization);
|
||||
return new VirtualMachineConfigurationOptions(href, type, links, actions, processor, memory, disk, networkAdapter, customization);
|
||||
}
|
||||
|
||||
public Builder fromVirtualMachineConfigurationOptions(VirtualMachineConfigurationOptions in) {
|
||||
|
@ -134,6 +136,29 @@ public class VirtualMachineConfigurationOptions extends BaseResource<VirtualMach
|
|||
return Builder.class.cast(super.href(href));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder fromAttributes(Map<String, String> attributes) {
|
||||
return Builder.class.cast(super.fromAttributes(attributes));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder links(Set<Link> links) {
|
||||
return Builder.class.cast(super.links(links));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Builder actions(Set<Action> actions) {
|
||||
return Builder.class.cast(super.actions(actions));
|
||||
}
|
||||
}
|
||||
|
||||
@XmlElement(name = "Processor", required = false)
|
||||
|
@ -151,9 +176,9 @@ public class VirtualMachineConfigurationOptions extends BaseResource<VirtualMach
|
|||
@XmlElement(name = "Customization", required = false)
|
||||
private CustomizationOption customization;
|
||||
|
||||
private VirtualMachineConfigurationOptions(URI href, String type, @Nullable ConfigurationOptionRange processor, @Nullable ResourceCapacityRange memory,
|
||||
private VirtualMachineConfigurationOptions(URI href, String type, Set<Link> links, Set<Action> actions, @Nullable ConfigurationOptionRange processor, @Nullable ResourceCapacityRange memory,
|
||||
@Nullable DiskConfigurationOption disk, @Nullable ConfigurationOptionRange networkAdapter, @Nullable CustomizationOption customization) {
|
||||
super(href, type);
|
||||
super(href, type, links, actions);
|
||||
this.processor = processor;
|
||||
this.memory = memory;
|
||||
this.disk = disk;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.tmrk.enterprisecloud.features;
|
||||
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.NamedResource;
|
||||
import org.jclouds.tmrk.enterprisecloud.domain.template.*;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -46,7 +47,7 @@ public class TemplateClientLiveTest extends BaseTerremarkEnterpriseCloudClientLi
|
|||
for(TemplateFamily family: templates.getTemplateFamilies()) {
|
||||
for(TemplateCategory category: family.getTemplateCategories()) {
|
||||
for(TemplateOperatingSystem os: category.getTemplateOperatingSystems()) {
|
||||
for(TemplateReference templateReference: os.getTemplates()) {
|
||||
for(NamedResource templateReference: os.getTemplates()) {
|
||||
testTemplate(templateReference);
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +55,7 @@ public class TemplateClientLiveTest extends BaseTerremarkEnterpriseCloudClientLi
|
|||
}
|
||||
}
|
||||
|
||||
private void testTemplate(TemplateReference templateReference) {
|
||||
private void testTemplate(NamedResource templateReference) {
|
||||
Template template = client.getTemplate(templateReference.getHref());
|
||||
assertNotNull(template);
|
||||
assertNotNull(template.getDescription());
|
||||
|
|
|
@ -101,7 +101,7 @@ public class TemplateJAXBParsingTest extends BaseRestClientTest {
|
|||
InputStream is = getClass().getResourceAsStream("/template.xml");
|
||||
Template template = parser.apply(new HttpResponse(200, "ok", newInputStreamPayload(is)));
|
||||
|
||||
assertLinks(template.getLinks().getLinks());
|
||||
assertLinks(template.getLinks());
|
||||
assertOperatingSystem(template.getOperatingSystem());
|
||||
assertEquals(template.getDescription(),"");
|
||||
assertProcessor(template.getProcessor());
|
||||
|
|
Loading…
Reference in New Issue