domain objects

This commit is contained in:
danikov 2012-02-09 19:08:14 +00:00
parent 0ff51f36ce
commit f3543a4c23
5 changed files with 1153 additions and 0 deletions

View File

@ -0,0 +1,300 @@
/**
* 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.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.NormalizedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import com.google.common.base.Objects;
import com.google.common.collect.Sets;
/**
*
* Represents a file to be transferred (uploaded or downloaded).
*
*
* <p>Java class for File complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="File">
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}EntityType">
* &lt;attribute name="size" type="{http://www.w3.org/2001/XMLSchema}long" />
* &lt;attribute name="bytesTransferred" type="{http://www.w3.org/2001/XMLSchema}long" />
* &lt;attribute name="checksum" type="{http://www.w3.org/2001/XMLSchema}normalizedString" />
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "File")
public class File
extends EntityType<File>
{
@SuppressWarnings("unchecked")
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromFile(this);
}
public static class Builder extends EntityType.Builder<File> {
private Long size;
private Long bytesTransferred;
private String checksum;
/**
* @see File#getSize()
*/
public Builder size(Long size) {
this.size = size;
return this;
}
/**
* @see File#getBytesTransferred()
*/
public Builder bytesTransferred(Long bytesTransferred) {
this.bytesTransferred = bytesTransferred;
return this;
}
/**
* @see File#getChecksum()
*/
public Builder checksum(String checksum) {
this.checksum = checksum;
return this;
}
public File build() {
File file = new File();
file.setSize(size);
file.setBytesTransferred(bytesTransferred);
file.setChecksum(checksum);
return file;
}
/**
* @see EntityType#getId()
*/
@Override
public Builder id(String id) {
this.id = id;
return this;
}
/**
* @see EntityType#getTasksInProgress()
*/
@Override
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
this.tasksInProgress = tasksInProgress;
return this;
}
/**
* @see ReferenceType#getHref()
*/
@Override
public Builder href(URI href) {
this.href = href;
return this;
}
/**
* @see ReferenceType#getType()
*/
@Override
public Builder type(String type) {
this.type = type;
return this;
}
/**
* @see ReferenceType#getLinks()
*/
@Override
public Builder links(Set<Link> links) {
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
return this;
}
/**
* @see ReferenceType#getLinks()
*/
@Override
public Builder link(Link link) {
this.links.add(checkNotNull(link, "link"));
return this;
}
@Override
public Builder fromEntityType(EntityType<File> in) {
return Builder.class.cast(super.fromEntityType(in));
}
public Builder fromFile(File in) {
return fromEntityType(in)
.size(in.getSize())
.bytesTransferred(in.getBytesTransferred())
.checksum(in.getChecksum());
}
}
private File() {
// For JAXB and builder use
}
@XmlAttribute
protected Long size;
@XmlAttribute
protected Long bytesTransferred;
@XmlAttribute
@XmlJavaTypeAdapter(NormalizedStringAdapter.class)
@XmlSchemaType(name = "normalizedString")
protected String checksum;
/**
* Gets the value of the size property.
*
* @return
* possible object is
* {@link Long }
*
*/
public Long getSize() {
return size;
}
/**
* Sets the value of the size property.
*
* @param value
* allowed object is
* {@link Long }
*
*/
public void setSize(Long value) {
this.size = value;
}
/**
* Gets the value of the bytesTransferred property.
*
* @return
* possible object is
* {@link Long }
*
*/
public Long getBytesTransferred() {
return bytesTransferred;
}
/**
* Sets the value of the bytesTransferred property.
*
* @param value
* allowed object is
* {@link Long }
*
*/
public void setBytesTransferred(Long value) {
this.bytesTransferred = value;
}
/**
* Gets the value of the checksum property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getChecksum() {
return checksum;
}
/**
* Sets the value of the checksum property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setChecksum(String value) {
this.checksum = value;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
File that = File.class.cast(o);
return equal(size, that.size) &&
equal(bytesTransferred, that.bytesTransferred) &&
equal(checksum, that.checksum);
}
@Override
public int hashCode() {
return Objects.hashCode(size,
bytesTransferred,
checksum);
}
@Override
public String toString() {
return Objects.toStringHelper("")
.add("size", size)
.add("bytesTransferred", bytesTransferred)
.add("checksum", checksum).toString();
}
}

View File

@ -0,0 +1,159 @@
/**
* 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.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
/**
*
* Represents a list of files to be transferred (uploaded
* or downloaded).
*
*
* <p>Java class for FilesList complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="FilesList">
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}VCloudExtensibleType">
* &lt;sequence>
* &lt;element name="File" type="{http://www.vmware.com/vcloud/v1.5}FileType" maxOccurs="unbounded"/>
* &lt;/sequence>
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "FilesList", propOrder = {
"file"
})
public class FilesList {
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromFilesList(this);
}
public static class Builder {
private List<File> files;
/**
* @see FilesList#getFile()
*/
public Builder file(List<File> file) {
this.files = file;
return this;
}
public FilesList build() {
FilesList filesList = new FilesList(files);
return filesList;
}
public Builder fromFilesList(FilesList in) {
return file(in.getFile());
}
}
private FilesList() {
// For JAXB and builder use
}
private FilesList(List<File> files) {
this.files = files;
}
@XmlElement(name = "File", required = true)
protected List<File> files;
/**
* Gets the value of the file property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the file property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getFile().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link FileType }
*
*
*/
public List<File> getFile() {
if (files == null) {
files = new ArrayList<File>();
}
return this.files;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
FilesList that = FilesList.class.cast(o);
return equal(files, that.files);
}
@Override
public int hashCode() {
return Objects.hashCode(files);
}
@Override
public String toString() {
return Objects.toStringHelper("")
.add("file", files).toString();
}
}

View File

@ -0,0 +1,230 @@
/**
* 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.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
/**
*
* Represents a media.
*
*
* <p>Java class for Media complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="Media">
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}ResourceEntityType">
* &lt;sequence>
* &lt;element name="Owner" type="{http://www.vmware.com/vcloud/v1.5}OwnerType" minOccurs="0"/>
* &lt;/sequence>
* &lt;attribute name="imageType" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="size" use="required" type="{http://www.w3.org/2001/XMLSchema}long" />
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Media", propOrder = {
"owner"
})
public class Media
extends ResourceEntityType<Media>
{
@SuppressWarnings("unchecked")
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromMedia(this);
}
public static class Builder extends ResourceEntityType.Builder<Media> {
private Owner owner;
private String imageType;
private long size;
/**
* @see Media#getOwner()
*/
public Builder owner(Owner owner) {
this.owner = owner;
return this;
}
/**
* @see Media#getImageType()
*/
public Builder imageType(String imageType) {
this.imageType = imageType;
return this;
}
/**
* @see Media#getSize()
*/
public Builder size(long size) {
this.size = size;
return this;
}
public Media build() {
Media media = new Media();
media.setOwner(owner);
media.setImageType(imageType);
media.setSize(size);
return media;
}
@Override
public Builder fromResourceEntityType(ResourceEntityType<Media> in) {
return Builder.class.cast(super.fromResourceEntityType(in));
}
public Builder fromMedia(Media in) {
return fromResourceEntityType(in)
.owner(in.getOwner())
.imageType(in.getImageType())
.size(in.getSize());
}
}
public Media() {
super();
}
@XmlElement(name = "Owner")
protected Owner owner;
@XmlAttribute(required = true)
protected String imageType;
@XmlAttribute(required = true)
protected long size;
/**
* Gets the value of the owner property.
*
* @return
* possible object is
* {@link Owner }
*
*/
public Owner getOwner() {
return owner;
}
/**
* Sets the value of the owner property.
*
* @param value
* allowed object is
* {@link Owner }
*
*/
public void setOwner(Owner value) {
this.owner = value;
}
/**
* Gets the value of the imageType property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getImageType() {
return imageType;
}
/**
* Sets the value of the imageType property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setImageType(String value) {
this.imageType = value;
}
/**
* Gets the value of the size property.
*
*/
public long getSize() {
return size;
}
/**
* Sets the value of the size property.
*
*/
public void setSize(long value) {
this.size = value;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Media that = Media.class.cast(o);
return equal(owner, that.owner) &&
equal(imageType, that.imageType) &&
equal(size, that.size);
}
@Override
public int hashCode() {
return Objects.hashCode(owner,
imageType,
size);
}
@Override
public String toString() {
return Objects.toStringHelper("")
.add("owner", owner)
.add("imageType", imageType)
.add("size", size).toString();
}
}

View File

@ -0,0 +1,199 @@
/**
* 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.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
import com.google.common.collect.Sets;
/**
*
* Represents the owner of this entity.
*
*
* <p>Java class for Owner complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="Owner">
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}ResourceType">
* &lt;sequence>
* &lt;element name="User" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType"/>
* &lt;/sequence>
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Owner", propOrder = {
"user"
})
public class Owner
extends ResourceType<Owner>
{
@SuppressWarnings("unchecked")
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromOwner(this);
}
public static class Builder extends ResourceType.Builder<Owner> {
private Reference user;
/**
* @see Owner#getUser()
*/
public Builder user(Reference user) {
this.user = user;
return this;
}
public Owner build() {
Owner owner = new Owner();
owner.setUser(user);
return owner;
}
/**
* @see ResourceType#getHref()
*/
@Override
public Builder href(URI href) {
super.href(href);
return this;
}
/**
* @see ResourceType#getType()
*/
@Override
public Builder type(String type) {
super.type(type);
return this;
}
/**
* @see ResourceType#getLinks()
*/
@Override
public Builder links(Set<Link> links) {
super.links(Sets.newLinkedHashSet(checkNotNull(links, "links")));
return this;
}
/**
* @see ResourceType#getLinks()
*/
@Override
public Builder link(Link link) {
super.link(link);
return this;
}
@Override
public Builder fromResourceType(ResourceType<Owner> in) {
return Builder.class.cast(super.fromResourceType(in));
}
public Builder fromOwner(Owner in) {
return fromResourceType(in)
.user(in.getUser());
}
}
private Owner() {
// For JAXB and builder use
}
@XmlElement(name = "User", required = true)
protected Reference user;
/**
* Gets the value of the user property.
*
* @return
* possible object is
* {@link Reference }
*
*/
public Reference getUser() {
return user;
}
/**
* Sets the value of the user property.
*
* @param value
* allowed object is
* {@link Reference }
*
*/
public void setUser(Reference value) {
this.user = value;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Owner that = Owner.class.cast(o);
return equal(user, that.user);
}
@Override
public int hashCode() {
return Objects.hashCode(user);
}
@Override
public String toString() {
return Objects.toStringHelper("")
.add("user", user).toString();
}
}

View File

@ -0,0 +1,265 @@
/**
* 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.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
import com.google.common.collect.Sets;
/**
*
* Base type that represents a resource entity such as a vApp
* template or virtual media.
*
*
* <p>Java class for ResourceEntity complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="ResourceEntity">
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}EntityType">
* &lt;sequence>
* &lt;element name="Files" type="{http://www.vmware.com/vcloud/v1.5}FilesListType" minOccurs="0"/>
* &lt;/sequence>
* &lt;attribute name="status" type="{http://www.w3.org/2001/XMLSchema}int" />
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ResourceEntity", propOrder = {
"files"
})
//@XmlSeeAlso({
// MediaType.class,
// VAppTemplateType.class,
// AbstractVAppType.class,
// NetworkPoolType.class
//})
public class ResourceEntityType<T extends ResourceEntityType<T>> extends EntityType<T> {
public static <T extends ResourceEntityType<T>> Builder<T> builder() {
return new Builder<T>();
}
@Override
public Builder<T> toBuilder() {
return new Builder<T>().fromResourceEntityType(this);
}
public static class Builder<T extends ResourceEntityType<T>> extends EntityType.Builder<T> {
private FilesList files;
private Integer status;
/**
* @see ResourceEntityType#getFiles()
*/
public Builder<T> files(FilesList files) {
this.files = files;
return this;
}
/**
* @see ResourceEntityType#getStatus()
*/
public Builder<T> status(Integer status) {
this.status = status;
return this;
}
public ResourceEntityType<T> build() {
ResourceEntityType<T> resourceEntity = new ResourceEntityType<T>();
resourceEntity.setFiles(files);
resourceEntity.setStatus(status);
return resourceEntity;
}
/**
* @see EntityType#getId()
*/
@Override
public Builder<T> id(String id) {
this.id = id;
return this;
}
/**
* @see EntityType#getTasksInProgress()
*/
@Override
public Builder<T> tasksInProgress(TasksInProgress tasksInProgress) {
this.tasksInProgress = tasksInProgress;
return this;
}
/**
* @see ReferenceType#getHref()
*/
@Override
public Builder<T> href(URI href) {
this.href = href;
return this;
}
/**
* @see ReferenceType#getType()
*/
@Override
public Builder<T> type(String type) {
this.type = type;
return this;
}
/**
* @see ReferenceType#getLinks()
*/
@Override
public Builder<T> links(Set<Link> links) {
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
return this;
}
/**
* @see ReferenceType#getLinks()
*/
@Override
public Builder<T> link(Link link) {
this.links.add(checkNotNull(link, "link"));
return this;
}
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public Builder<T> fromResourceType(ResourceType<T> in) {
return Builder.class.cast(super.fromResourceType(in));
}
public Builder<T> fromResourceEntityType(ResourceEntityType<T> in) {
return fromResourceType(in)
.files(in.getFiles())
.status(in.getStatus());
}
}
public ResourceEntityType() {
}
@XmlElement(name = "Files")
protected FilesList files;
@XmlAttribute
protected Integer status;
/**
* Gets the value of the files property.
*
* @return
* possible object is
* {@link FilesList }
*
*/
public FilesList getFiles() {
return files;
}
/**
* Sets the value of the files property.
*
* @param value
* allowed object is
* {@link FilesList }
*
*/
public void setFiles(FilesList value) {
this.files = value;
}
/**
* Gets the value of the status property.
*
* @return
* possible object is
* {@link Integer }
*
*/
public Integer getStatus() {
return status;
}
/**
* Sets the value of the status property.
*
* @param value
* allowed object is
* {@link Integer }
*
*/
public void setStatus(Integer value) {
this.status = value;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
ResourceEntityType<?> that = ResourceEntityType.class.cast(o);
return equal(files, that.files) &&
equal(status, that.status);
}
@Override
public int hashCode() {
return Objects.hashCode(files,
status);
}
@Override
public String toString() {
return Objects.toStringHelper("")
.add("files", files)
.add("status", status).toString();
}
}