mirror of https://github.com/apache/jclouds.git
glesys: bean cleaning, using ConstructorProperties for deserialization (note no serialization annotations as we don't currently serialize any of these beans)
This commit is contained in:
parent
fd79c479af
commit
b1877bbee5
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,12 +20,12 @@ package org.jclouds.glesys.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Sets the allowed arguments for some of the functions in this module such as disksize, cpucores etc.
|
||||
|
@ -34,79 +34,104 @@ import com.google.gson.annotations.SerializedName;
|
|||
* @see <a href="https://customer.glesys.com/api.php?a=doc#server_allowedarguments" />
|
||||
*/
|
||||
public class AllowedArgumentsForCreateServer {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private Set<Integer> diskSizes;
|
||||
private Set<Integer> memorySizes;
|
||||
private Set<Integer> cpuCores;
|
||||
private Set<String> templates;
|
||||
private Set<Integer> transfers;
|
||||
private Set<String> dataCenters;
|
||||
|
||||
public Builder diskSizes(Integer... sizes) {
|
||||
return diskSizes(ImmutableSet.<Integer>copyOf(sizes));
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromAllowedArgumentsForCreateServer(this);
|
||||
}
|
||||
|
||||
public Builder diskSizes(Set<Integer> sizes) {
|
||||
this.diskSizes = sizes;
|
||||
return this;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected Set<Integer> diskSizes = ImmutableSet.of();
|
||||
protected Set<Integer> memorySizes = ImmutableSet.of();
|
||||
protected Set<Integer> cpuCores = ImmutableSet.of();
|
||||
protected Set<String> templates = ImmutableSet.of();
|
||||
protected Set<Integer> transfers = ImmutableSet.of();
|
||||
protected Set<String> dataCenters = ImmutableSet.of();
|
||||
|
||||
/**
|
||||
* @see AllowedArgumentsForCreateServer#getDiskSizesInGB()
|
||||
*/
|
||||
public T diskSizes(Set<Integer> diskSizes) {
|
||||
this.diskSizes = ImmutableSet.copyOf(checkNotNull(diskSizes, "diskSizesInGB"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder memorySizes(Integer... sizes) {
|
||||
return memorySizes(ImmutableSet.<Integer>copyOf(sizes));
|
||||
public T diskSizes(Integer... in) {
|
||||
return diskSizes(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public Builder memorySizes(Set<Integer> sizes) {
|
||||
this.memorySizes = sizes;
|
||||
return this;
|
||||
/**
|
||||
* @see AllowedArgumentsForCreateServer#getMemorySizesInMB()
|
||||
*/
|
||||
public T memorySizes(Set<Integer> memorySizes) {
|
||||
this.memorySizes = ImmutableSet.copyOf(checkNotNull(memorySizes, "memorySizesInMB"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder cpuCores(Integer... cpuCores) {
|
||||
this.cpuCores = ImmutableSet.<Integer>copyOf(cpuCores);
|
||||
return this;
|
||||
public T memorySizes(Integer... in) {
|
||||
return memorySizes(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public Builder cpuCores(Set<Integer> cpuCores) {
|
||||
this.cpuCores = cpuCores;
|
||||
return this;
|
||||
/**
|
||||
* @see AllowedArgumentsForCreateServer#getCpuCoreOptions()
|
||||
*/
|
||||
public T cpuCores(Set<Integer> cpuCores) {
|
||||
this.cpuCores = ImmutableSet.copyOf(checkNotNull(cpuCores, "cpuCoreOptions"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder templates(String... templates) {
|
||||
return templates(ImmutableSet.<String>copyOf(templates));
|
||||
public T cpuCores(Integer... in) {
|
||||
return cpuCores(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public Builder templates(Set<String> templates) {
|
||||
this.templates = templates;
|
||||
return this;
|
||||
/**
|
||||
* @see AllowedArgumentsForCreateServer#getTemplateNames()
|
||||
*/
|
||||
public T templates(Set<String> templates) {
|
||||
this.templates = ImmutableSet.copyOf(checkNotNull(templates, "templateNames"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder transfers(Integer... transfers) {
|
||||
return transfers(ImmutableSet.<Integer>copyOf(transfers));
|
||||
public T templates(String... in) {
|
||||
return templates(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public Builder transfers(Set<Integer> transfers) {
|
||||
this.transfers = transfers;
|
||||
return this;
|
||||
/**
|
||||
* @see AllowedArgumentsForCreateServer#getTransfersInGB()
|
||||
*/
|
||||
public T transfers(Set<Integer> transfers) {
|
||||
this.transfers = ImmutableSet.copyOf(checkNotNull(transfers, "transfersInGB"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder dataCenters(String... dataCenters) {
|
||||
return dataCenters(ImmutableSet.<String>copyOf(dataCenters));
|
||||
public T transfers(Integer... in) {
|
||||
return transfers(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public Builder dataCenters(Set<String> dataCenters) {
|
||||
this.dataCenters = dataCenters;
|
||||
return this;
|
||||
/**
|
||||
* @see AllowedArgumentsForCreateServer#getDataCenters()
|
||||
*/
|
||||
public T dataCenters(Set<String> dataCenters) {
|
||||
this.dataCenters = ImmutableSet.copyOf(checkNotNull(dataCenters, "dataCenters"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public T dataCenters(String... in) {
|
||||
return dataCenters(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public AllowedArgumentsForCreateServer build() {
|
||||
return new AllowedArgumentsForCreateServer(diskSizes, memorySizes, cpuCores, templates, transfers, dataCenters);
|
||||
}
|
||||
|
||||
public Builder fromAllowedArguments(AllowedArgumentsForCreateServer in) {
|
||||
return diskSizes(in.getDiskSizesInGB())
|
||||
public T fromAllowedArgumentsForCreateServer(AllowedArgumentsForCreateServer in) {
|
||||
return this
|
||||
.diskSizes(in.getDiskSizesInGB())
|
||||
.memorySizes(in.getMemorySizesInMB())
|
||||
.cpuCores(in.getCpuCoreOptions())
|
||||
.templates(in.getTemplateNames())
|
||||
|
@ -115,34 +140,30 @@ public class AllowedArgumentsForCreateServer {
|
|||
}
|
||||
}
|
||||
|
||||
@SerializedName("disksize")
|
||||
private final Set<Integer> diskSizes;
|
||||
@SerializedName("memorysize")
|
||||
private final Set<Integer> memorySizes;
|
||||
@SerializedName("cpucores")
|
||||
private final Set<Integer> cpuCores;
|
||||
@SerializedName("template")
|
||||
private final Set<String> templates;
|
||||
@SerializedName("transfer")
|
||||
private final Set<Integer> transfers;
|
||||
@SerializedName("datacenter")
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final Set<Integer> diskSizesInGB;
|
||||
private final Set<Integer> memorySizesInMB;
|
||||
private final Set<Integer> cpuCoreOptions;
|
||||
private final Set<String> templateNames;
|
||||
private final Set<Integer> transfersInGB;
|
||||
private final Set<String> dataCenters;
|
||||
|
||||
public AllowedArgumentsForCreateServer(Set<Integer> diskSizes, Set<Integer> memorySizes, Set<Integer> cpuCores,
|
||||
Set<String> templates, Set<Integer> transfers, Set<String> dataCenters) {
|
||||
checkNotNull(diskSizes, "diskSizes");
|
||||
checkNotNull(memorySizes, "memorySizes");
|
||||
checkNotNull(cpuCores, "cpuCores");
|
||||
checkNotNull(templates, "templates");
|
||||
checkNotNull(transfers, "transfers");
|
||||
checkNotNull(dataCenters, "dataCenters");
|
||||
|
||||
this.diskSizes = diskSizes;
|
||||
this.memorySizes = memorySizes;
|
||||
this.cpuCores = cpuCores;
|
||||
this.templates = templates;
|
||||
this.transfers = transfers;
|
||||
this.dataCenters = dataCenters;
|
||||
@ConstructorProperties({
|
||||
"disksize", "memorysize", "cpucores", "template", "transfer", "datacenter"
|
||||
})
|
||||
protected AllowedArgumentsForCreateServer(Set<Integer> diskSizesInGB, Set<Integer> memorySizesInMB, Set<Integer> cpuCoreOptions, Set<String> templateNames, Set<Integer> transfersInGB, Set<String> dataCenters) {
|
||||
this.diskSizesInGB = ImmutableSet.copyOf(checkNotNull(diskSizesInGB, "diskSizesInGB"));
|
||||
this.memorySizesInMB = ImmutableSet.copyOf(checkNotNull(memorySizesInMB, "memorySizesInMB"));
|
||||
this.cpuCoreOptions = ImmutableSet.copyOf(checkNotNull(cpuCoreOptions, "cpuCoreOptions"));
|
||||
this.templateNames = ImmutableSet.copyOf(checkNotNull(templateNames, "templateNames"));
|
||||
this.transfersInGB = ImmutableSet.copyOf(checkNotNull(transfersInGB, "transfersInGB"));
|
||||
this.dataCenters = ImmutableSet.copyOf(checkNotNull(dataCenters, "dataCenters"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,7 +171,7 @@ public class AllowedArgumentsForCreateServer {
|
|||
* @see org.jclouds.glesys.domain.OSTemplate#getMinDiskSize()
|
||||
*/
|
||||
public Set<Integer> getDiskSizesInGB() {
|
||||
return diskSizes;
|
||||
return this.diskSizesInGB;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,14 +179,14 @@ public class AllowedArgumentsForCreateServer {
|
|||
* @see org.jclouds.glesys.domain.OSTemplate#getMinMemSize()
|
||||
*/
|
||||
public Set<Integer> getMemorySizesInMB() {
|
||||
return memorySizes;
|
||||
return this.memorySizesInMB;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list of which core counts can be used for creating servers on this platform
|
||||
*/
|
||||
public Set<Integer> getCpuCoreOptions() {
|
||||
return cpuCores;
|
||||
return this.cpuCoreOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -173,59 +194,50 @@ public class AllowedArgumentsForCreateServer {
|
|||
* @see org.jclouds.glesys.domain.OSTemplate#getName()
|
||||
*/
|
||||
public Set<String> getTemplateNames() {
|
||||
return templates;
|
||||
return this.templateNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list of transfer settings available for creating servers on this platform
|
||||
*/
|
||||
public Set<Integer> getTransfersInGB() {
|
||||
return transfers;
|
||||
return this.transfersInGB;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list of datacenters available that support creating servers on this platform
|
||||
*/
|
||||
public Set<String> getDataCenters() {
|
||||
return dataCenters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof AllowedArgumentsForCreateServer) {
|
||||
final AllowedArgumentsForCreateServer other = (AllowedArgumentsForCreateServer) object;
|
||||
return Objects.equal(diskSizes, other.diskSizes)
|
||||
&& Objects.equal(memorySizes, other.memorySizes)
|
||||
&& Objects.equal(cpuCores, other.cpuCores)
|
||||
&& Objects.equal(templates, other.templates)
|
||||
&& Objects.equal(transfers, other.transfers)
|
||||
&& Objects.equal(dataCenters, other.dataCenters);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return this.dataCenters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(diskSizes, memorySizes, cpuCores, templates, transfers, dataCenters);
|
||||
return Objects.hashCode(diskSizesInGB, memorySizesInMB, cpuCoreOptions, templateNames, transfersInGB, dataCenters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
AllowedArgumentsForCreateServer that = AllowedArgumentsForCreateServer.class.cast(obj);
|
||||
return Objects.equal(this.diskSizesInGB, that.diskSizesInGB)
|
||||
&& Objects.equal(this.memorySizesInMB, that.memorySizesInMB)
|
||||
&& Objects.equal(this.cpuCoreOptions, that.cpuCoreOptions)
|
||||
&& Objects.equal(this.templateNames, that.templateNames)
|
||||
&& Objects.equal(this.transfersInGB, that.transfersInGB)
|
||||
&& Objects.equal(this.dataCenters, that.dataCenters);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("").add("diskSizesInGB", diskSizesInGB).add("memorySizesInMB", memorySizesInMB)
|
||||
.add("cpuCoreOptions", cpuCoreOptions).add("templateNames", templateNames)
|
||||
.add("transfersInGB", transfersInGB).add("dataCenters", dataCenters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
checkNotNull(diskSizes, "diskSizes");
|
||||
checkNotNull(memorySizes, "memorySizes");
|
||||
checkNotNull(cpuCores, "cpuCores");
|
||||
checkNotNull(templates, "templates");
|
||||
checkNotNull(transfers, "transfers");
|
||||
checkNotNull(dataCenters, "dataCenters");
|
||||
|
||||
Joiner commaJoiner = Joiner.on(", ");
|
||||
return String.format("[disksize=[%s], memorysize=[%s], cpuCores=[%s], templates=[%s], transfers=[%s], datacenters=[%s]]",
|
||||
commaJoiner.join(diskSizes), commaJoiner.join(memorySizes), commaJoiner.join(cpuCores), commaJoiner.join(templates),
|
||||
commaJoiner.join(transfers), commaJoiner.join(dataCenters));
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,8 +18,12 @@
|
|||
*/
|
||||
package org.jclouds.glesys.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Information about an archive
|
||||
|
@ -27,102 +31,143 @@ import com.google.gson.annotations.SerializedName;
|
|||
* @author Adam Lowe
|
||||
* @see <a href= "https://customer.glesys.com/api.php?a=doc#archive_list" />
|
||||
*/
|
||||
public class Archive implements Comparable<Archive> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public class Archive {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromArchive(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String username;
|
||||
protected String totalSize;
|
||||
protected String freeSize;
|
||||
protected boolean locked;
|
||||
|
||||
public Builder username(String username) {
|
||||
this.username = username;
|
||||
return this;
|
||||
/**
|
||||
* @see Archive#getUsername()
|
||||
*/
|
||||
public T username(String username) {
|
||||
this.username = checkNotNull(username, "username");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder totalSize(String totalSize) {
|
||||
this.totalSize = totalSize;
|
||||
return this;
|
||||
/**
|
||||
* @see Archive#getTotalSize()
|
||||
*/
|
||||
public T totalSize(String totalSize) {
|
||||
this.totalSize = checkNotNull(totalSize, "totalSize");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder freeSize(String freeSize) {
|
||||
this.freeSize = freeSize;
|
||||
return this;
|
||||
/**
|
||||
* @see Archive#getFreeSize()
|
||||
*/
|
||||
public T freeSize(String freeSize) {
|
||||
this.freeSize = checkNotNull(freeSize, "freeSize");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder locked(boolean locked) {
|
||||
/**
|
||||
* @see Archive#isLocked()
|
||||
*/
|
||||
public T locked(boolean locked) {
|
||||
this.locked = locked;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Archive build() {
|
||||
return new Archive(username, totalSize, freeSize, locked);
|
||||
return new Archive(username, totalSize, freeSize, new GleSYSBoolean(locked));
|
||||
}
|
||||
|
||||
public Builder fromArchive(Archive in) {
|
||||
return username(in.getUsername()).totalSize(in.getTotalSize()).freeSize(in.getFreeSize()).locked(in.isLocked());
|
||||
public T fromArchive(Archive in) {
|
||||
return this
|
||||
.username(in.getUsername())
|
||||
.totalSize(in.getTotalSize())
|
||||
.freeSize(in.getFreeSize())
|
||||
.locked(in.isLocked());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final String username;
|
||||
@SerializedName("size_total")
|
||||
private final String totalSize;
|
||||
@SerializedName("size_free")
|
||||
private final String freeSize;
|
||||
private final boolean locked;
|
||||
|
||||
/** @return the name (username) of the archive */
|
||||
@ConstructorProperties({
|
||||
"username", "sizetotal", "sizefree", "locked"
|
||||
})
|
||||
protected Archive(String username, String totalSize, String freeSize, GleSYSBoolean locked) {
|
||||
this.username = checkNotNull(username, "username");
|
||||
this.totalSize = checkNotNull(totalSize, "totalSize");
|
||||
this.freeSize = checkNotNull(freeSize, "freeSize");
|
||||
this.locked = checkNotNull(locked, "locked").getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name (username) of the archive
|
||||
*/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
return this.username;
|
||||
}
|
||||
|
||||
/** @return the total size of the archive, ex. "10 GB" */
|
||||
/**
|
||||
* @return the total size of the archive, ex. "10 GB"
|
||||
*/
|
||||
public String getTotalSize() {
|
||||
return totalSize;
|
||||
return this.totalSize;
|
||||
}
|
||||
|
||||
/** @return the free space left of the archive */
|
||||
/**
|
||||
* @return the free space left of the archive
|
||||
*/
|
||||
public String getFreeSize() {
|
||||
return freeSize;
|
||||
return this.freeSize;
|
||||
}
|
||||
|
||||
/** @return true if the archive is locked */
|
||||
/**
|
||||
* @return true if the archive is locked
|
||||
*/
|
||||
public boolean isLocked() {
|
||||
return locked;
|
||||
}
|
||||
|
||||
public Archive(String username, String totalSize, String freeSize, boolean locked) {
|
||||
this.username = username;
|
||||
this.totalSize = totalSize;
|
||||
this.freeSize = freeSize;
|
||||
this.locked = locked;
|
||||
return this.locked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Archive other) {
|
||||
return username.compareTo(other.getUsername());
|
||||
return Objects.hashCode(username, totalSize, freeSize, locked);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Archive that = Archive.class.cast(obj);
|
||||
return Objects.equal(this.username, that.username)
|
||||
&& Objects.equal(this.totalSize, that.totalSize)
|
||||
&& Objects.equal(this.freeSize, that.freeSize)
|
||||
&& Objects.equal(this.locked, that.locked);
|
||||
}
|
||||
return obj instanceof Archive
|
||||
&& Objects.equal(username, ((Archive) obj).username);
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("username", username).add("totalSize", totalSize).add("freeSize", freeSize).add("locked", locked);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[username=%s, totalSize=%s, freeSize=%s, locked=%b]", username, totalSize, freeSize, locked);
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,14 +18,14 @@
|
|||
*/
|
||||
package org.jclouds.glesys.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
/**
|
||||
* The allowed arguments for archive manipulation, such as archivesize
|
||||
|
@ -34,53 +34,62 @@ import com.google.gson.annotations.SerializedName;
|
|||
* @see <a href= "https://customer.glesys.com/api.php?a=doc#archive_allowedarguments" />
|
||||
*/
|
||||
public class ArchiveAllowedArguments {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private List<Integer> archiveSizes;
|
||||
|
||||
public Builder archiveSizes(List<Integer> archiveSizes) {
|
||||
this.archiveSizes = archiveSizes;
|
||||
return this;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromArchiveAllowedArguments(this);
|
||||
}
|
||||
|
||||
public Builder archiveSizes(Integer... archiveSizes) {
|
||||
return archiveSizes(Arrays.asList(archiveSizes));
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected List<Integer> archiveSizes = ImmutableList.of();
|
||||
|
||||
/**
|
||||
* @see ArchiveAllowedArguments#getArchiveSizes()
|
||||
*/
|
||||
public T archiveSizes(List<Integer> archiveSizes) {
|
||||
this.archiveSizes = ImmutableList.copyOf(checkNotNull(archiveSizes, "archiveSizes"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public T archiveSizes(Integer... in) {
|
||||
return archiveSizes(ImmutableList.copyOf(in));
|
||||
}
|
||||
|
||||
public ArchiveAllowedArguments build() {
|
||||
return new ArchiveAllowedArguments(archiveSizes);
|
||||
}
|
||||
|
||||
public Builder fromArchiveAllowedArguments(ArchiveAllowedArguments in) {
|
||||
return archiveSizes(in.getArchiveSizes());
|
||||
public T fromArchiveAllowedArguments(ArchiveAllowedArguments in) {
|
||||
return this.archiveSizes(in.getArchiveSizes());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@SerializedName("archivesize")
|
||||
private final List<Integer> archiveSizes;
|
||||
|
||||
public ArchiveAllowedArguments(List<Integer> archiveSizes) {
|
||||
checkArgument(archiveSizes != null, "archiveSizes");
|
||||
this.archiveSizes = archiveSizes;
|
||||
@ConstructorProperties({
|
||||
"archivesize"
|
||||
})
|
||||
protected ArchiveAllowedArguments(List<Integer> archiveSizes) {
|
||||
this.archiveSizes = ImmutableList.copyOf(checkNotNull(archiveSizes, "archiveSizes"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list of allowed archive sizes, in GB
|
||||
*/
|
||||
public List<Integer> getArchiveSizes() {
|
||||
return archiveSizes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
return object instanceof ArchiveAllowedArguments
|
||||
&& Objects.equal(archiveSizes, ((ArchiveAllowedArguments) object).archiveSizes);
|
||||
return this.archiveSizes;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -88,11 +97,22 @@ public class ArchiveAllowedArguments {
|
|||
return Objects.hashCode(archiveSizes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ArchiveAllowedArguments that = ArchiveAllowedArguments.class.cast(obj);
|
||||
return Objects.equal(this.archiveSizes, that.archiveSizes);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("archiveSizes", archiveSizes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
Joiner commaJoiner = Joiner.on(", ");
|
||||
return String.format(
|
||||
"[archiveSizes=[%s]]", commaJoiner.join(archiveSizes));
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,7 +18,12 @@
|
|||
*/
|
||||
package org.jclouds.glesys.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Connection information to connect to a server with VNC.
|
||||
|
@ -27,44 +32,69 @@ import com.google.common.base.Objects;
|
|||
* @see <a href="https://customer.glesys.com/api.php?a=doc#server_console" />
|
||||
*/
|
||||
public class Console {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String host;
|
||||
private int port;
|
||||
private String protocol;
|
||||
private String password;
|
||||
|
||||
public Builder host(String host) {
|
||||
this.host = host;
|
||||
return this;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromConsole(this);
|
||||
}
|
||||
|
||||
public Builder port(int port) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String host;
|
||||
protected int port;
|
||||
protected String protocol;
|
||||
protected String password;
|
||||
|
||||
/**
|
||||
* @see Console#getHost()
|
||||
*/
|
||||
public T host(String host) {
|
||||
this.host = checkNotNull(host, "host");
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Console#getPort()
|
||||
*/
|
||||
public T port(int port) {
|
||||
this.port = port;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder password(String password) {
|
||||
this.password = password;
|
||||
return this;
|
||||
/**
|
||||
* @see Console#getProtocol()
|
||||
*/
|
||||
public T protocol(String protocol) {
|
||||
this.protocol = checkNotNull(protocol, "protocol");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder protocol(String protocol) {
|
||||
this.protocol = protocol;
|
||||
return this;
|
||||
/**
|
||||
* @see Console#getPassword()
|
||||
*/
|
||||
public T password(String password) {
|
||||
this.password = checkNotNull(password, "password");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Console build() {
|
||||
return new Console(host, port, protocol, password);
|
||||
}
|
||||
|
||||
public Builder fromConsole(Console in) {
|
||||
return host(in.getHost()).port(in.getPort()).password(in.getPassword()).protocol(in.getProtocol());
|
||||
public T fromConsole(Console in) {
|
||||
return this.host(in.getHost()).port(in.getPort()).protocol(in.getProtocol()).password(in.getPassword());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final String host;
|
||||
|
@ -72,54 +102,42 @@ public class Console {
|
|||
private final String protocol;
|
||||
private final String password;
|
||||
|
||||
public Console(String host, int port, String protocol, String password) {
|
||||
this.host = host;
|
||||
@ConstructorProperties({
|
||||
"host", "port", "protocol", "password"
|
||||
})
|
||||
protected Console(String host, int port, String protocol, String password) {
|
||||
this.host = checkNotNull(host, "host");
|
||||
this.port = port;
|
||||
this.protocol = protocol;
|
||||
this.password = password;
|
||||
this.protocol = checkNotNull(protocol, "protocol");
|
||||
this.password = checkNotNull(password, "password");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the host name to use to connect to the server
|
||||
*/
|
||||
public String getHost() {
|
||||
return host;
|
||||
return this.host;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the port to use to connect to the server
|
||||
*/
|
||||
public int getPort() {
|
||||
return port;
|
||||
return this.port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the protocol to use to connect to the server
|
||||
*/
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
return this.protocol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the password to use to connect to the server
|
||||
*/
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof Console) {
|
||||
final Console other = (Console) object;
|
||||
return Objects.equal(host, other.host)
|
||||
&& Objects.equal(port, other.port)
|
||||
&& Objects.equal(protocol, other.protocol);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return this.password;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -127,9 +145,24 @@ public class Console {
|
|||
return Objects.hashCode(host, port, protocol);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Console that = Console.class.cast(obj);
|
||||
return Objects.equal(this.host, that.host)
|
||||
&& Objects.equal(this.port, that.port)
|
||||
&& Objects.equal(this.protocol, that.protocol);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("").add("host", host).add("port", port).add("protocol", protocol)
|
||||
.add("password", password);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[host=%s, port=%s, protocol=%s, password=%s]", host, port, protocol, password);
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,8 +20,10 @@ package org.jclouds.glesys.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* The Cost class contains information about the cost of a server
|
||||
|
@ -30,84 +32,94 @@ import com.google.gson.annotations.SerializedName;
|
|||
* @see ServerDetails
|
||||
*/
|
||||
public class Cost {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private double amount;
|
||||
private String currency;
|
||||
private String timePeriod;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromCost(this);
|
||||
}
|
||||
|
||||
public Builder amount(double amount) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected double amount;
|
||||
protected String currency;
|
||||
protected String timePeriod;
|
||||
|
||||
/**
|
||||
* @see Cost#getAmount()
|
||||
*/
|
||||
public T amount(double amount) {
|
||||
this.amount = amount;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder currency(String currency) {
|
||||
this.currency = currency;
|
||||
return this;
|
||||
/**
|
||||
* @see Cost#getCurrency()
|
||||
*/
|
||||
public T currency(String currency) {
|
||||
this.currency = checkNotNull(currency, "currency");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder timePeriod(String timePeriod) {
|
||||
this.timePeriod = timePeriod;
|
||||
return this;
|
||||
/**
|
||||
* @see Cost#getTimePeriod()
|
||||
*/
|
||||
public T timePeriod(String timePeriod) {
|
||||
this.timePeriod = checkNotNull(timePeriod, "timePeriod");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Cost build() {
|
||||
return new Cost(amount, currency, timePeriod);
|
||||
}
|
||||
|
||||
public Builder fromCost(Cost cost) {
|
||||
return amount(cost.getAmount()).currency(cost.getCurrency()).timePeriod(cost.getTimePeriod());
|
||||
public T fromCost(Cost in) {
|
||||
return this.amount(in.getAmount()).currency(in.getCurrency()).timePeriod(in.getTimePeriod());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final double amount;
|
||||
private final String currency;
|
||||
@SerializedName("timeperiod")
|
||||
private final String timePeriod;
|
||||
|
||||
public Cost(double amount, String currency, String timePeriod) {
|
||||
@ConstructorProperties({
|
||||
"amount", "currency", "timeperiod"
|
||||
})
|
||||
protected Cost(double amount, String currency, String timePeriod) {
|
||||
this.amount = amount;
|
||||
this.currency = checkNotNull(currency, "currency");
|
||||
this.timePeriod = timePeriod;
|
||||
this.timePeriod = checkNotNull(timePeriod, "timePeriod");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the numeric cost in #currency / #timePeriod
|
||||
*/
|
||||
public double getAmount() {
|
||||
return amount;
|
||||
return this.amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the currency unit, e.g. "EUR" for Euro
|
||||
*/
|
||||
public String getCurrency() {
|
||||
return currency;
|
||||
return this.currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the time period for which this cost charged, e.g. "month"
|
||||
*/
|
||||
public String getTimePeriod() {
|
||||
return timePeriod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof Cost) {
|
||||
Cost other = (Cost) object;
|
||||
return Objects.equal(amount, other.amount)
|
||||
&& Objects.equal(currency, other.currency)
|
||||
&& Objects.equal(timePeriod, other.timePeriod);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return this.timePeriod;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -115,9 +127,23 @@ public class Cost {
|
|||
return Objects.hashCode(amount, currency, timePeriod);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Cost that = Cost.class.cast(obj);
|
||||
return Objects.equal(this.amount, that.amount)
|
||||
&& Objects.equal(this.currency, that.currency)
|
||||
&& Objects.equal(this.timePeriod, that.timePeriod);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("amount", amount).add("currency", currency).add("timePeriod", timePeriod);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(
|
||||
"[amount=%f, currency=%s, timePeriod=%s]", amount, currency, timePeriod);
|
||||
return string().toString();
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,10 +18,15 @@
|
|||
*/
|
||||
package org.jclouds.glesys.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Domain data for a Glesys account.
|
||||
|
@ -29,80 +34,253 @@ import com.google.gson.annotations.SerializedName;
|
|||
* @author Adam Lowe
|
||||
* @see <a href= "https://customer.glesys.com/api.php?a=doc#domain_list" />
|
||||
*/
|
||||
public class Domain implements Comparable<Domain> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public class Domain {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String domainName;
|
||||
private Date createTime;
|
||||
private int recordCount;
|
||||
private boolean useGlesysNameServer;
|
||||
|
||||
public Builder domainName(String domainName) {
|
||||
this.domainName = domainName;
|
||||
return this;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromDomain(this);
|
||||
}
|
||||
|
||||
public Builder createTime(Date createTime) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String domainName;
|
||||
protected Date createTime;
|
||||
protected int recordCount;
|
||||
protected boolean useGlesysNameServer;
|
||||
protected String primaryNameServer;
|
||||
protected String responsiblePerson;
|
||||
protected int ttl;
|
||||
protected int refresh;
|
||||
protected int retry;
|
||||
protected int expire;
|
||||
protected int minimum;
|
||||
|
||||
/**
|
||||
* @see Domain#getDomainName()
|
||||
*/
|
||||
public T domainName(String domainName) {
|
||||
this.domainName = checkNotNull(domainName, "domainName");
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Domain#getCreateTime()
|
||||
*/
|
||||
public T createTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder recordCount(int recordCount) {
|
||||
/**
|
||||
* @see Domain#getRecordCount()
|
||||
*/
|
||||
public T recordCount(int recordCount) {
|
||||
this.recordCount = recordCount;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder useGlesysNameServer(boolean useGlesysNameServer) {
|
||||
/**
|
||||
* @see Domain#isUseGlesysNameServer()
|
||||
*/
|
||||
public T useGlesysNameServer(boolean useGlesysNameServer) {
|
||||
this.useGlesysNameServer = useGlesysNameServer;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Domain#getPrimaryNameServer()
|
||||
*/
|
||||
public T primaryNameServer(String primaryNameServer) {
|
||||
this.primaryNameServer = primaryNameServer;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Domain#getResponsiblePerson()
|
||||
*/
|
||||
public T responsiblePerson(String responsiblePerson) {
|
||||
this.responsiblePerson = responsiblePerson;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Domain#getTtl()
|
||||
*/
|
||||
public T ttl(int ttl) {
|
||||
this.ttl = ttl;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Domain#getRefresh()
|
||||
*/
|
||||
public T refresh(int refresh) {
|
||||
this.refresh = refresh;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Domain#getRetry()
|
||||
*/
|
||||
public T retry(int retry) {
|
||||
this.retry = retry;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Domain#getExpire()
|
||||
*/
|
||||
public T expire(int expire) {
|
||||
this.expire = expire;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Domain#getMinimum()
|
||||
*/
|
||||
public T minimum(int minimum) {
|
||||
this.minimum = minimum;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Domain build() {
|
||||
return new Domain(domainName, createTime, recordCount, useGlesysNameServer);
|
||||
return new Domain(domainName, createTime, recordCount, new GleSYSBoolean(useGlesysNameServer), primaryNameServer, responsiblePerson, ttl, refresh, retry, expire, minimum);
|
||||
}
|
||||
|
||||
public Builder fromDomain(Domain in) {
|
||||
return new Builder().domainName(in.getDomainName()).createTime(in.getCreateTime()).recordCount(in.getRecordCount()).useGlesysNameServer(in.isGlesysNameServer());
|
||||
public T fromDomain(Domain in) {
|
||||
return this.domainName(in.getDomainName())
|
||||
.createTime(in.getCreateTime())
|
||||
.recordCount(in.getRecordCount())
|
||||
.useGlesysNameServer(in.isUseGlesysNameServer())
|
||||
.primaryNameServer(in.getPrimaryNameServer())
|
||||
.responsiblePerson(in.getResponsiblePerson())
|
||||
.ttl(in.getTtl())
|
||||
.refresh(in.getRefresh())
|
||||
.retry(in.getRetry())
|
||||
.expire(in.getExpire());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@SerializedName("domainname")
|
||||
private final String domainName;
|
||||
@SerializedName("createtime")
|
||||
private final Date createTime;
|
||||
@SerializedName("recordcount")
|
||||
private final int recordCount;
|
||||
@SerializedName("usingglesysnameserver")
|
||||
private final boolean useGlesysNameServer;
|
||||
private final String primaryNameServer;
|
||||
private final String responsiblePerson;
|
||||
private final int ttl;
|
||||
private final int refresh;
|
||||
private final int retry;
|
||||
private final int expire;
|
||||
private final int minimum;
|
||||
|
||||
public Domain(String domainName, Date createTime, int recordCount, boolean useGlesysNameServer) {
|
||||
this.domainName = domainName;
|
||||
@ConstructorProperties({
|
||||
"domainname", "createtime", "recordcount", "usingglesysnameserver", "primarynameserver", "responsibleperson",
|
||||
"ttl", "refresh", "retry", "expire", "minimum"
|
||||
})
|
||||
protected Domain(String domainName, @Nullable Date createTime, int recordCount, GleSYSBoolean useGlesysNameServer,
|
||||
@Nullable String primaryNameServer, @Nullable String responsiblePerson,
|
||||
int ttl, int refresh, int retry, int expire, int minimum) {
|
||||
this.domainName = checkNotNull(domainName, "domainName");
|
||||
this.createTime = createTime;
|
||||
this.recordCount = recordCount;
|
||||
this.useGlesysNameServer = useGlesysNameServer;
|
||||
this.useGlesysNameServer = checkNotNull(useGlesysNameServer, "useGlesysNameServer").getValue();
|
||||
this.primaryNameServer = primaryNameServer;
|
||||
this.responsiblePerson = responsiblePerson;
|
||||
this.ttl = ttl;
|
||||
this.refresh = refresh;
|
||||
this.retry = retry;
|
||||
this.expire = expire;
|
||||
this.minimum = minimum;
|
||||
}
|
||||
|
||||
/** @return the domain name, ex. "jclouds.org" */
|
||||
/**
|
||||
* @return the domain name, ex. "jclouds.org"
|
||||
*/
|
||||
public String getDomainName() {
|
||||
return domainName;
|
||||
return this.domainName;
|
||||
}
|
||||
|
||||
/** @return the date the domain was registered with GleSYS */
|
||||
/**
|
||||
* @return the date the domain was registered with GleSYS
|
||||
*/
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
return this.createTime;
|
||||
}
|
||||
|
||||
/** @return the number of DNS records for this domain */
|
||||
/**
|
||||
* @return the number of DNS records for this domain
|
||||
*/
|
||||
public int getRecordCount() {
|
||||
return recordCount;
|
||||
return this.recordCount;
|
||||
}
|
||||
|
||||
/** @return true if a GleSYS nameserver holds the records */
|
||||
public boolean isGlesysNameServer() {
|
||||
return useGlesysNameServer;
|
||||
/**
|
||||
* @return true if a GleSYS nameserver holds the records
|
||||
*/
|
||||
public boolean isUseGlesysNameServer() {
|
||||
return this.useGlesysNameServer;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPrimaryNameServer() {
|
||||
return primaryNameServer;
|
||||
}
|
||||
|
||||
/**
|
||||
* The E-mail address of the person responsible for this domain (reformatted with '.' at end).
|
||||
*/
|
||||
@Nullable
|
||||
public String getResponsiblePerson() {
|
||||
return responsiblePerson;
|
||||
}
|
||||
|
||||
/**
|
||||
* TTL (time to live). The number of seconds a domain name is cached locally before expiration and return to authoritative nameServers for updates
|
||||
*/
|
||||
public int getTtl() {
|
||||
return ttl;
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of seconds between update requests from secondary and slave name servers
|
||||
*/
|
||||
public int getRefresh() {
|
||||
return refresh;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The number of seconds the secondary/slave will wait before retrying when the last attempt failed
|
||||
*/
|
||||
public int getRetry() {
|
||||
return retry;
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of seconds a master or slave will wait before considering the data stale if it cannot reach the primary name server
|
||||
*/
|
||||
public int getExpire() {
|
||||
return expire;
|
||||
}
|
||||
|
||||
/**
|
||||
* The minimum/default TTL if the domain does not specify ttl
|
||||
*
|
||||
* @see #getTtl()
|
||||
*/
|
||||
public int getMinimum() {
|
||||
return minimum;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -111,25 +289,21 @@ public class Domain implements Comparable<Domain> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Domain other) {
|
||||
return domainName.compareTo(other.getDomainName());
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Domain that = Domain.class.cast(obj);
|
||||
return Objects.equal(this.domainName, that.domainName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof Domain) {
|
||||
return Objects.equal(domainName, ((Domain) object).domainName);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("domainName", domainName).add("createTime", createTime).add("recordCount", recordCount).add("useGlesysNameServer", useGlesysNameServer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[domainname=%s, createtime=%s, count=%d, useglesysnameserver=%b]", domainName, createTime, recordCount, useGlesysNameServer);
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,7 +18,14 @@
|
|||
*/
|
||||
package org.jclouds.glesys.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* DNS record data.
|
||||
|
@ -26,55 +33,92 @@ import com.google.common.base.Objects;
|
|||
* @author Adam Lowe
|
||||
* @see <a href= "https://customer.glesys.com/api.php?a=doc#domain_list_records" />
|
||||
*/
|
||||
public class DomainRecord implements Comparable<DomainRecord> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public class DomainRecord {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String id;
|
||||
private String domainname;
|
||||
private String host;
|
||||
private String type;
|
||||
private String data;
|
||||
private int ttl;
|
||||
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromDomainRecord(this);
|
||||
}
|
||||
|
||||
public Builder domainname(String domainname) {
|
||||
this.domainname = domainname;
|
||||
return this;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String id;
|
||||
protected String domainname;
|
||||
protected String host;
|
||||
protected String type;
|
||||
protected String data;
|
||||
protected int ttl;
|
||||
|
||||
/**
|
||||
* @see DomainRecord#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder host(String host) {
|
||||
this.host = host;
|
||||
return this;
|
||||
/**
|
||||
* @see DomainRecord#getDomainname()
|
||||
*/
|
||||
public T domainname(String domainname) {
|
||||
this.domainname = checkNotNull(domainname, "domainname");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder type(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
/**
|
||||
* @see DomainRecord#getHost()
|
||||
*/
|
||||
public T host(String host) {
|
||||
this.host = checkNotNull(host, "host");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder data(String data) {
|
||||
this.data = data;
|
||||
return this;
|
||||
/**
|
||||
* @see DomainRecord#getType()
|
||||
*/
|
||||
public T type(String type) {
|
||||
this.type = checkNotNull(type, "type");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder ttl(int ttl) {
|
||||
/**
|
||||
* @see DomainRecord#getData()
|
||||
*/
|
||||
public T data(String data) {
|
||||
this.data = checkNotNull(data, "data");
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DomainRecord#getTtl()
|
||||
*/
|
||||
public T ttl(int ttl) {
|
||||
this.ttl = ttl;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public DomainRecord build() {
|
||||
return new DomainRecord(id, domainname, host, type, data, ttl);
|
||||
}
|
||||
|
||||
public Builder fromDomainRecord(DomainRecord in) {
|
||||
return new Builder().id(in.getId()).domainname(in.getDomainName()).host(in.getHost()).type(in.getType()).data(in.getData()).ttl(in.getTtl());
|
||||
public T fromDomainRecord(DomainRecord in) {
|
||||
return this.id(in.getId())
|
||||
.domainname(in.getDomainname())
|
||||
.host(in.getHost())
|
||||
.type(in.getType())
|
||||
.data(in.getData())
|
||||
.ttl(in.getTtl());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,11 +129,14 @@ public class DomainRecord implements Comparable<DomainRecord> {
|
|||
private final String data;
|
||||
private final int ttl;
|
||||
|
||||
public DomainRecord(String id, String domainname, String host, String type, String data, int ttl) {
|
||||
@ConstructorProperties({
|
||||
"recordid", "domainname", "host", "type", "data", "ttl"
|
||||
})
|
||||
protected DomainRecord(@Nullable String id, String domainname, String host, String type, @Nullable String data, int ttl) {
|
||||
this.id = id;
|
||||
this.domainname = domainname;
|
||||
this.host = host;
|
||||
this.type = type;
|
||||
this.domainname = checkNotNull(domainname, "domainname");
|
||||
this.host = checkNotNull(host, "host");
|
||||
this.type = checkNotNull(type, "type");
|
||||
this.data = data;
|
||||
this.ttl = ttl;
|
||||
}
|
||||
|
@ -99,47 +146,43 @@ public class DomainRecord implements Comparable<DomainRecord> {
|
|||
* @see org.jclouds.glesys.features.DomainClient
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the zone content of the record
|
||||
*/
|
||||
public String getDomainName() {
|
||||
return domainname;
|
||||
public String getDomainname() {
|
||||
return this.domainname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the host content of the record
|
||||
*/
|
||||
public String getHost() {
|
||||
return host;
|
||||
return this.host;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type of the record, ex. "A"
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
return this.type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the data content of the record
|
||||
*/
|
||||
@Nullable
|
||||
public String getData() {
|
||||
return data;
|
||||
return this.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the TTL/Time-to-live for the record
|
||||
*/
|
||||
public int getTtl() {
|
||||
return ttl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(DomainRecord other) {
|
||||
return id.compareTo(other.getId());
|
||||
return this.ttl;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -148,21 +191,22 @@ public class DomainRecord implements Comparable<DomainRecord> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof DomainRecord) {
|
||||
DomainRecord other = (DomainRecord) object;
|
||||
return Objects.equal(id, other.id);
|
||||
} else {
|
||||
return false;
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
DomainRecord that = DomainRecord.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("id", id).add("domainname", domainname).add("host", host).add("type", type).add("data", data)
|
||||
.add("ttl", ttl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[id=%s, domainname=%s, host=%s, type=%s, data=%s, ttl=%d]", id, domainname, host, type, data, ttl);
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,10 +18,15 @@
|
|||
*/
|
||||
package org.jclouds.glesys.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Date;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Detailed information on an Email Account
|
||||
|
@ -29,181 +34,214 @@ import com.google.gson.annotations.SerializedName;
|
|||
* @author Adam Lowe
|
||||
* @see <a href="https://customer.glesys.com/api.php?a=doc#email_list" />
|
||||
*/
|
||||
public class EmailAccount implements Comparable<EmailAccount> {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public class EmailAccount {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String account;
|
||||
private String quota;
|
||||
private String usedQuota;
|
||||
private int antispamLevel;
|
||||
private boolean antiVirus;
|
||||
private boolean autoRespond;
|
||||
private String autoRespondMessage;
|
||||
private boolean autoRespondSaveEmail;
|
||||
private Date created;
|
||||
private Date modified;
|
||||
|
||||
public Builder account(String account) {
|
||||
this.account = account;
|
||||
return this;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromEmailAccount(this);
|
||||
}
|
||||
|
||||
public Builder quota(String quota) {
|
||||
this.quota = quota;
|
||||
return this;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String account;
|
||||
protected EmailQuota quota;
|
||||
protected int antispamLevel;
|
||||
protected boolean antiVirus;
|
||||
protected boolean autoRespond;
|
||||
protected String autoRespondMessage;
|
||||
protected boolean autoRespondSaveEmail;
|
||||
protected Date created;
|
||||
protected Date modified;
|
||||
|
||||
/**
|
||||
* @see EmailAccount#getAccount()
|
||||
*/
|
||||
public T account(String account) {
|
||||
this.account = checkNotNull(account, "account");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder usedQuota(String usedQuota) {
|
||||
this.usedQuota = usedQuota;
|
||||
return this;
|
||||
/**
|
||||
* @see EmailAccount#getQuota()
|
||||
*/
|
||||
public T quota(EmailQuota quota) {
|
||||
this.quota = checkNotNull(quota, "quota");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder antispamLevel(int antispamLevel) {
|
||||
/**
|
||||
* @see EmailAccount#getAntispamLevel()
|
||||
*/
|
||||
public T antispamLevel(int antispamLevel) {
|
||||
this.antispamLevel = antispamLevel;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder antiVirus(boolean antiVirus) {
|
||||
/**
|
||||
* @see EmailAccount#isAntiVirus()
|
||||
*/
|
||||
public T antiVirus(boolean antiVirus) {
|
||||
this.antiVirus = antiVirus;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder autoRespond(boolean autoRespond) {
|
||||
/**
|
||||
* @see EmailAccount#isAutoRespond()
|
||||
*/
|
||||
public T autoRespond(boolean autoRespond) {
|
||||
this.autoRespond = autoRespond;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder autoRespondMessage(String autoRespondMessage) {
|
||||
this.autoRespondMessage = autoRespondMessage;
|
||||
return this;
|
||||
/**
|
||||
* @see EmailAccount#getAutoRespondMessage()
|
||||
*/
|
||||
public T autoRespondMessage(String autoRespondMessage) {
|
||||
this.autoRespondMessage = checkNotNull(autoRespondMessage, "autoRespondMessage");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder autoRespondSaveEmail(boolean autoRespondSaveEmail) {
|
||||
/**
|
||||
* @see EmailAccount#isAutoRespondSaveEmail()
|
||||
*/
|
||||
public T autoRespondSaveEmail(boolean autoRespondSaveEmail) {
|
||||
this.autoRespondSaveEmail = autoRespondSaveEmail;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder created(Date created) {
|
||||
this.created = created;
|
||||
return this;
|
||||
/**
|
||||
* @see EmailAccount#getCreated()
|
||||
*/
|
||||
public T created(Date created) {
|
||||
this.created = checkNotNull(created, "created");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder modified(Date modified) {
|
||||
this.modified = modified;
|
||||
return this;
|
||||
/**
|
||||
* @see EmailAccount#getModified()
|
||||
*/
|
||||
public T modified(Date modified) {
|
||||
this.modified = checkNotNull(modified, "modified");
|
||||
return self();
|
||||
}
|
||||
|
||||
public EmailAccount build() {
|
||||
return new EmailAccount(account, quota, usedQuota, antispamLevel, antiVirus, autoRespond, autoRespondMessage,
|
||||
autoRespondSaveEmail, created, modified);
|
||||
return new EmailAccount(account, quota, antispamLevel, new GleSYSBoolean(antiVirus), new GleSYSBoolean(autoRespond), autoRespondMessage, new GleSYSBoolean(autoRespondSaveEmail), created, modified);
|
||||
}
|
||||
|
||||
public Builder fromEmail(EmailAccount in) {
|
||||
return account(in.getAccount()).quota(in.getQuota()).usedQuota(in.getUsedQuota()).antispamLevel(in.getAntispamLevel()).
|
||||
antiVirus(in.getAntiVirus()).autoRespond(in.getAutoRespond()).autoRespondMessage(in.getAutoRespondMessage()).
|
||||
autoRespondSaveEmail(in.getAutoRespondSaveEmail()).created(in.getCreated()).modified(in.getModified());
|
||||
public T fromEmailAccount(EmailAccount in) {
|
||||
return this.account(in.getAccount())
|
||||
.quota(in.getQuota())
|
||||
.antispamLevel(in.getAntispamLevel())
|
||||
.antiVirus(in.isAntiVirus())
|
||||
.autoRespond(in.isAutoRespond())
|
||||
.autoRespondMessage(in.getAutoRespondMessage())
|
||||
.autoRespondSaveEmail(in.isAutoRespondSaveEmail())
|
||||
.created(in.getCreated())
|
||||
.modified(in.getModified());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@SerializedName("emailaccount")
|
||||
private final String account;
|
||||
private final String quota;
|
||||
@SerializedName("usedquota")
|
||||
private final String usedQuota;
|
||||
@SerializedName("antispamlevel")
|
||||
private final EmailQuota quota;
|
||||
private final int antispamLevel;
|
||||
@SerializedName("antivirus")
|
||||
private final boolean antiVirus;
|
||||
@SerializedName("autorespond")
|
||||
private final boolean autoRespond;
|
||||
@SerializedName("autorespondmessage")
|
||||
private final String autoRespondMessage;
|
||||
@SerializedName("autorespondsaveemail")
|
||||
private final boolean autoRespondSaveEmail;
|
||||
private final Date created;
|
||||
private final Date modified;
|
||||
|
||||
public EmailAccount(String account, String quota, String usedQuota, int antispamLevel, boolean antiVirus, boolean autoRespond, String autoRespondMessage, boolean autoRespondSaveEmail, Date created, Date modified) {
|
||||
this.account = account;
|
||||
this.quota = quota;
|
||||
this.usedQuota = usedQuota;
|
||||
@ConstructorProperties({
|
||||
"emailaccount", "quota", "usedquota", "antispamlevel", "antivirus", "autorespond", "autorespondmessage", "autorespondsaveemail", "created", "modified"
|
||||
})
|
||||
protected EmailAccount(String account, EmailQuota quota, int antispamLevel,
|
||||
GleSYSBoolean antiVirus, GleSYSBoolean autoRespond, @Nullable String autoRespondMessage,
|
||||
GleSYSBoolean autoRespondSaveEmail, Date created, @Nullable Date modified) {
|
||||
this.account = checkNotNull(account, "account");
|
||||
this.quota = checkNotNull(quota, "quota");
|
||||
this.antispamLevel = antispamLevel;
|
||||
this.antiVirus = antiVirus;
|
||||
this.autoRespond = autoRespond;
|
||||
this.antiVirus = checkNotNull(antiVirus, "antiVirus").getValue();
|
||||
this.autoRespond = checkNotNull(autoRespond, "autoRespond").getValue();
|
||||
this.autoRespondMessage = autoRespondMessage;
|
||||
this.autoRespondSaveEmail = autoRespondSaveEmail;
|
||||
this.created = created;
|
||||
this.autoRespondSaveEmail = checkNotNull(autoRespondSaveEmail, "autoRespondSaveEmail").getValue();
|
||||
this.created = checkNotNull(created, "created");
|
||||
this.modified = modified;
|
||||
}
|
||||
|
||||
/** @return the e-mail address for this e-mail account */
|
||||
/**
|
||||
* @return the e-mail address for this e-mail account
|
||||
*/
|
||||
public String getAccount() {
|
||||
return account;
|
||||
return this.account;
|
||||
}
|
||||
|
||||
/** @return the quota for this e-mail account */
|
||||
public String getQuota() {
|
||||
return quota;
|
||||
/**
|
||||
* @return the quota for this e-mail account
|
||||
*/
|
||||
public EmailQuota getQuota() {
|
||||
return this.quota;
|
||||
}
|
||||
|
||||
/** @return the amount of quota currently in use */
|
||||
public String getUsedQuota() {
|
||||
return usedQuota;
|
||||
}
|
||||
|
||||
/** @return the antispam level of the e-mail account */
|
||||
/**
|
||||
* @return the antispam level of the e-mail account
|
||||
*/
|
||||
public int getAntispamLevel() {
|
||||
return antispamLevel;
|
||||
return this.antispamLevel;
|
||||
}
|
||||
|
||||
/** @return true if antivirus is enabled for this e-mail account */
|
||||
public boolean getAntiVirus() {
|
||||
return antiVirus;
|
||||
/**
|
||||
* @return true if antivirus is enabled for this e-mail account
|
||||
*/
|
||||
public boolean isAntiVirus() {
|
||||
return this.antiVirus;
|
||||
}
|
||||
|
||||
/** @return true if auto-respond is enabled for this e-mail account */
|
||||
public boolean getAutoRespond() {
|
||||
return autoRespond;
|
||||
/**
|
||||
* @return true if auto-respond is enabled for this e-mail account
|
||||
*/
|
||||
public boolean isAutoRespond() {
|
||||
return this.autoRespond;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the auto-respond message for this e-mail account
|
||||
*/
|
||||
@Nullable
|
||||
public String getAutoRespondMessage() {
|
||||
return autoRespondMessage;
|
||||
return this.autoRespondMessage;
|
||||
}
|
||||
|
||||
/** @return true if saving is enabled for auto-respond e-mails */
|
||||
public boolean getAutoRespondSaveEmail() {
|
||||
return autoRespondSaveEmail;
|
||||
/**
|
||||
* @return true if saving is enabled for auto-respond e-mails
|
||||
*/
|
||||
public boolean isAutoRespondSaveEmail() {
|
||||
return this.autoRespondSaveEmail;
|
||||
}
|
||||
|
||||
/** @return when this account was created */
|
||||
/**
|
||||
* @return when this account was created
|
||||
*/
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
return this.created;
|
||||
}
|
||||
|
||||
/** @return when this account was last modified */
|
||||
/**
|
||||
* @return when this account was last modified
|
||||
*/
|
||||
@Nullable
|
||||
public Date getModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(EmailAccount other) {
|
||||
return account.compareTo(other.getAccount());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof EmailAccount) {
|
||||
EmailAccount other = (EmailAccount) object;
|
||||
return Objects.equal(account, other.account);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return this.modified;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -211,12 +249,22 @@ public class EmailAccount implements Comparable<EmailAccount> {
|
|||
return Objects.hashCode(account);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
EmailAccount that = EmailAccount.class.cast(obj);
|
||||
return Objects.equal(this.account, that.account);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("account", account).add("quota", quota).add("antispamLevel", antispamLevel).add("antiVirus", antiVirus).add("autoRespond", autoRespond).add("autoRespondMessage", autoRespondMessage).add("autoRespondSaveEmail", autoRespondSaveEmail).add("created", created).add("modified", modified);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("account=%s, quota=%s, usedquota=%s, antispamLevel=%d, " +
|
||||
"antiVirus=%b, autoRespond=%b, autoRespondMessage=%s, autoRespondSaveEmail=%b, " +
|
||||
"created=%s, modified=%s", account, quota, usedQuota, antispamLevel, antiVirus, autoRespond, autoRespondMessage,
|
||||
autoRespondSaveEmail, created.toString(), modified.toString());
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* 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.glesys.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Detailed information on an Email Account
|
||||
*
|
||||
* @author Adam Lowe
|
||||
* @see <a href="https://customer.glesys.com/api.php?a=doc#email_list" />
|
||||
*/
|
||||
public class EmailAlias {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromEmailAccount(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String account;
|
||||
protected String forwardTo;
|
||||
|
||||
/**
|
||||
* @see org.jclouds.glesys.domain.EmailAlias#getAccount()
|
||||
*/
|
||||
public T account(String account) {
|
||||
this.account = checkNotNull(account, "account");
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EmailAlias#getForwardTo()
|
||||
*/
|
||||
public T forwardTo(String forwardTo) {
|
||||
this.forwardTo = checkNotNull(forwardTo, "forwardTo");
|
||||
return self();
|
||||
}
|
||||
|
||||
public EmailAlias build() {
|
||||
return new EmailAlias(account, forwardTo);
|
||||
}
|
||||
|
||||
public T fromEmailAccount(EmailAlias in) {
|
||||
return this.account(in.getAccount()).forwardTo(in.getForwardTo());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final String account;
|
||||
private final String forwardTo;
|
||||
|
||||
@ConstructorProperties({
|
||||
"emailalias", "goto"
|
||||
})
|
||||
protected EmailAlias(String account, String forwardTo) {
|
||||
this.account = checkNotNull(account, "account");
|
||||
this.forwardTo = checkNotNull(forwardTo, "forwardTo");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the e-mail address being forwarded
|
||||
*/
|
||||
public String getAccount() {
|
||||
return this.account;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the e-mail address this address forwards to
|
||||
*/
|
||||
public String getForwardTo() {
|
||||
return this.forwardTo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(account);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
EmailAlias that = EmailAlias.class.cast(obj);
|
||||
return Objects.equal(this.account, that.account);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("account", account).add("forwardTo", forwardTo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,11 +18,14 @@
|
|||
*/
|
||||
package org.jclouds.glesys.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
|
@ -34,53 +37,80 @@ import com.google.common.collect.ImmutableSet;
|
|||
//TODO: find a better name for this class
|
||||
@Beta
|
||||
public class EmailOverview {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private EmailOverviewSummary summary;
|
||||
private Set<EmailOverviewDomain> domains;
|
||||
|
||||
public Builder summary(EmailOverviewSummary summary) {
|
||||
this.summary = summary;
|
||||
return this;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromEmailOverview(this);
|
||||
}
|
||||
|
||||
public Builder domains(Set<EmailOverviewDomain> domains) {
|
||||
this.domains = domains;
|
||||
return this;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected EmailOverviewSummary summary;
|
||||
protected Set<EmailOverviewDomain> domains = ImmutableSet.of();
|
||||
|
||||
/**
|
||||
* @see EmailOverview#getSummary()
|
||||
*/
|
||||
public T summary(EmailOverviewSummary summary) {
|
||||
this.summary = checkNotNull(summary, "summary");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder domains(EmailOverviewDomain... domains) {
|
||||
return domains(ImmutableSet.copyOf(domains));
|
||||
/**
|
||||
* @see EmailOverview#getDomains()
|
||||
*/
|
||||
public T domains(Set<EmailOverviewDomain> domains) {
|
||||
this.domains = ImmutableSet.copyOf(checkNotNull(domains, "domains"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public T domains(EmailOverviewDomain... in) {
|
||||
return domains(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public EmailOverview build() {
|
||||
return new EmailOverview(summary, domains);
|
||||
}
|
||||
|
||||
public Builder fromEmailOverview(EmailOverview in) {
|
||||
return summary(in.getSummary()).domains(in.getDomains());
|
||||
public T fromEmailOverview(EmailOverview in) {
|
||||
return this.summary(in.getSummary()).domains(in.getDomains());
|
||||
}
|
||||
}
|
||||
|
||||
private EmailOverviewSummary summary;
|
||||
private Set<EmailOverviewDomain> domains;
|
||||
|
||||
public EmailOverview(EmailOverviewSummary summary, Set<EmailOverviewDomain> domains) {
|
||||
this.summary = summary;
|
||||
this.domains = domains;
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/** @return summary information about the account */
|
||||
private final EmailOverviewSummary summary;
|
||||
private final Set<EmailOverviewDomain> domains;
|
||||
|
||||
@ConstructorProperties({
|
||||
"summary", "domains"
|
||||
})
|
||||
protected EmailOverview(EmailOverviewSummary summary, Set<EmailOverviewDomain> domains) {
|
||||
this.summary = checkNotNull(summary, "summary");
|
||||
this.domains = ImmutableSet.copyOf(checkNotNull(domains, "domains"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return summary information about the account
|
||||
*/
|
||||
public EmailOverviewSummary getSummary() {
|
||||
return summary;
|
||||
return this.summary;
|
||||
}
|
||||
|
||||
/** @return the set of detailed information about the e-mail addresses and aliases for each domain */
|
||||
/**
|
||||
* @return the set of detailed information about the e-mail addresses and aliases for each domain
|
||||
*/
|
||||
public Set<EmailOverviewDomain> getDomains() {
|
||||
return domains == null ? ImmutableSet.<EmailOverviewDomain>of() : domains;
|
||||
return this.domains;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -89,23 +119,22 @@ public class EmailOverview {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (object == this) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof EmailOverview) {
|
||||
EmailOverview other = (EmailOverview) object;
|
||||
return Objects.equal(summary, other.summary)
|
||||
&& Objects.equal(domains, other.domains);
|
||||
} else {
|
||||
return false;
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
EmailOverview that = EmailOverview.class.cast(obj);
|
||||
return Objects.equal(this.summary, that.summary)
|
||||
&& Objects.equal(this.domains, that.domains);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("summary", summary).add("domains", domains);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
Joiner commaJoiner = Joiner.on(", ");
|
||||
return String.format("summary=%s, domains=[%s]", summary, commaJoiner.join(getDomains()));
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,8 +18,13 @@
|
|||
*/
|
||||
package org.jclouds.glesys.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Detailed information about e-mail settings for a single domain
|
||||
|
@ -27,39 +32,61 @@ import com.google.common.base.Objects;
|
|||
* @author Adam Lowe
|
||||
* @see <a href="https://customer.glesys.com/api.php?a=doc#email_overview" />
|
||||
*/
|
||||
//TODO: find a better name for this class
|
||||
@Beta
|
||||
public class EmailOverviewDomain {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String domain;
|
||||
private int accounts;
|
||||
private int aliases;
|
||||
|
||||
public Builder domain(String domain) {
|
||||
this.domain = domain;
|
||||
return this;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromEmailOverviewDomain(this);
|
||||
}
|
||||
|
||||
public Builder accounts(int accounts) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String domain;
|
||||
protected int accounts;
|
||||
protected int aliases;
|
||||
|
||||
/**
|
||||
* @see EmailOverviewDomain#getDomain()
|
||||
*/
|
||||
public T domain(String domain) {
|
||||
this.domain = checkNotNull(domain, "domain");
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EmailOverviewDomain#getAccounts()
|
||||
*/
|
||||
public T accounts(int accounts) {
|
||||
this.accounts = accounts;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder aliases(int aliases) {
|
||||
/**
|
||||
* @see EmailOverviewDomain#getAliases()
|
||||
*/
|
||||
public T aliases(int aliases) {
|
||||
this.aliases = aliases;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public EmailOverviewDomain build() {
|
||||
return new EmailOverviewDomain(domain, accounts, aliases);
|
||||
}
|
||||
|
||||
public Builder fromEmailOverview(EmailOverviewDomain in) {
|
||||
return domain(domain).accounts(in.getAccounts()).aliases(in.getAliases());
|
||||
public T fromEmailOverviewDomain(EmailOverviewDomain in) {
|
||||
return this.domain(in.getDomain()).accounts(in.getAccounts()).aliases(in.getAliases());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,25 +94,28 @@ public class EmailOverviewDomain {
|
|||
private final int accounts;
|
||||
private final int aliases;
|
||||
|
||||
public EmailOverviewDomain(String domain, int accounts, int aliases) {
|
||||
this.domain = domain;
|
||||
@ConstructorProperties({
|
||||
"domainname", "accounts", "aliases"
|
||||
})
|
||||
protected EmailOverviewDomain(String domain, int accounts, int aliases) {
|
||||
this.domain = checkNotNull(domain, "domain");
|
||||
this.accounts = accounts;
|
||||
this.aliases = aliases;
|
||||
}
|
||||
|
||||
/** @return the domain name */
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
return this.domain;
|
||||
}
|
||||
|
||||
/** @return the number of e-mail accounts in the domain */
|
||||
public int getAccounts() {
|
||||
return accounts;
|
||||
return this.accounts;
|
||||
}
|
||||
|
||||
/** @return the number of e-mail aliases in the domain */
|
||||
public int getAliases() {
|
||||
return aliases;
|
||||
return this.aliases;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -94,21 +124,20 @@ public class EmailOverviewDomain {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (object == this) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof EmailOverviewDomain) {
|
||||
EmailOverviewDomain other = (EmailOverviewDomain) object;
|
||||
return Objects.equal(domain, other.domain);
|
||||
} else {
|
||||
return false;
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
EmailOverviewDomain that = EmailOverviewDomain.class.cast(obj);
|
||||
return Objects.equal(this.domain, that.domain);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("").add("domain", domain).add("accounts", accounts).add("aliases", aliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("domain=%s, accounts=%d, aliases=%d", domain, accounts, aliases);
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,9 +18,11 @@
|
|||
*/
|
||||
package org.jclouds.glesys.domain;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Summary information of e-mail settings and limits for a GleSYS account
|
||||
|
@ -31,77 +33,115 @@ import com.google.gson.annotations.SerializedName;
|
|||
//TODO: find a better name for this class
|
||||
@Beta
|
||||
public class EmailOverviewSummary {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private int accounts;
|
||||
private int maxAccounts;
|
||||
private int aliases;
|
||||
private int maxAliases;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromEmailOverviewSummary(this);
|
||||
}
|
||||
|
||||
public Builder accounts(int accounts) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected int accounts;
|
||||
protected int maxAccounts;
|
||||
protected int aliases;
|
||||
protected int maxAliases;
|
||||
|
||||
/**
|
||||
* @see EmailOverviewSummary#getAccounts()
|
||||
*/
|
||||
public T accounts(int accounts) {
|
||||
this.accounts = accounts;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder maxAccounts(int maxAccounts) {
|
||||
/**
|
||||
* @see EmailOverviewSummary#getMaxAccounts()
|
||||
*/
|
||||
public T maxAccounts(int maxAccounts) {
|
||||
this.maxAccounts = maxAccounts;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder aliases(int aliases) {
|
||||
/**
|
||||
* @see EmailOverviewSummary#getAliases()
|
||||
*/
|
||||
public T aliases(int aliases) {
|
||||
this.aliases = aliases;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder maxAliases(int maxAliases) {
|
||||
/**
|
||||
* @see EmailOverviewSummary#getMaxAliases()
|
||||
*/
|
||||
public T maxAliases(int maxAliases) {
|
||||
this.maxAliases = maxAliases;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public EmailOverviewSummary build() {
|
||||
return new EmailOverviewSummary(accounts, maxAccounts, aliases, maxAliases);
|
||||
}
|
||||
|
||||
public Builder fromEmailOverview(EmailOverviewSummary in) {
|
||||
return accounts(in.getAccounts()).maxAccounts(in.getMaxAccounts()).aliases(in.getAliases()).maxAliases(in.getMaxAliases());
|
||||
public T fromEmailOverviewSummary(EmailOverviewSummary in) {
|
||||
return this.accounts(in.getAccounts())
|
||||
.maxAccounts(in.getMaxAccounts())
|
||||
.aliases(in.getAliases())
|
||||
.maxAliases(in.getMaxAliases());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final int accounts;
|
||||
@SerializedName("maxaccounts")
|
||||
private final int maxAccounts;
|
||||
private final int aliases;
|
||||
@SerializedName("maxaliases")
|
||||
private final int maxAliases;
|
||||
|
||||
public EmailOverviewSummary(int accounts, int maxAccounts, int aliases, int maxAliases) {
|
||||
@ConstructorProperties({
|
||||
"accounts", "maxaccounts", "aliases", "maxaliases"
|
||||
})
|
||||
protected EmailOverviewSummary(int accounts, int maxAccounts, int aliases, int maxAliases) {
|
||||
this.accounts = accounts;
|
||||
this.maxAccounts = maxAccounts;
|
||||
this.aliases = aliases;
|
||||
this.maxAliases = maxAliases;
|
||||
}
|
||||
|
||||
/** @return the number of e-mail accounts */
|
||||
/**
|
||||
* @return the number of e-mail accounts
|
||||
*/
|
||||
public int getAccounts() {
|
||||
return accounts;
|
||||
return this.accounts;
|
||||
}
|
||||
|
||||
/** @return the maximum number of e-mail accounts */
|
||||
/**
|
||||
* @return the maximum number of e-mail accounts
|
||||
*/
|
||||
public int getMaxAccounts() {
|
||||
return maxAccounts;
|
||||
return this.maxAccounts;
|
||||
}
|
||||
|
||||
/** @return the number of e-mail aliases */
|
||||
/**
|
||||
* @return the number of e-mail aliases
|
||||
*/
|
||||
public int getAliases() {
|
||||
return aliases;
|
||||
return this.aliases;
|
||||
}
|
||||
|
||||
/** @return the maximum number of e-mail aliases */
|
||||
/**
|
||||
* @return the maximum number of e-mail aliases
|
||||
*/
|
||||
public int getMaxAliases() {
|
||||
return maxAliases;
|
||||
return this.maxAliases;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -110,24 +150,24 @@ public class EmailOverviewSummary {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (object == this) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof EmailOverviewSummary) {
|
||||
EmailOverviewSummary other = (EmailOverviewSummary) object;
|
||||
return Objects.equal(accounts, other.accounts)
|
||||
&& Objects.equal(maxAccounts, other.maxAccounts)
|
||||
&& Objects.equal(aliases, other.aliases)
|
||||
&& Objects.equal(maxAliases, other.maxAliases);
|
||||
} else {
|
||||
return false;
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
EmailOverviewSummary that = EmailOverviewSummary.class.cast(obj);
|
||||
return Objects.equal(this.accounts, that.accounts)
|
||||
&& Objects.equal(this.maxAccounts, that.maxAccounts)
|
||||
&& Objects.equal(this.aliases, that.aliases)
|
||||
&& Objects.equal(this.maxAliases, that.maxAliases);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("accounts", accounts).add("maxAccounts", maxAccounts).add("aliases", aliases).add("maxAliases", maxAliases);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("accounts=%d, maxAccounts=%d, aliases=%d, maxAliases=%d", accounts, maxAccounts, aliases, maxAliases);
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* 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.glesys.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Information on an Email Account Quota size
|
||||
*
|
||||
* @author Adam Lowe
|
||||
* @see <a href="https://customer.glesys.com/api.php?a=doc#email_list" />
|
||||
*/
|
||||
public class EmailQuota {
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromEmailAccount(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected int max;
|
||||
protected String unit;
|
||||
|
||||
/**
|
||||
* @see EmailQuota#getMax()
|
||||
*/
|
||||
public T max(int max) {
|
||||
this.max = max;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see EmailQuota#getUnit()
|
||||
*/
|
||||
public T unit(String unit) {
|
||||
this.unit = checkNotNull(unit, "unit");
|
||||
return self();
|
||||
}
|
||||
|
||||
public EmailQuota build() {
|
||||
return new EmailQuota(max, unit);
|
||||
}
|
||||
|
||||
public T fromEmailAccount(EmailQuota in) {
|
||||
return this.max(in.getMax()).unit(in.getUnit());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final int max;
|
||||
private final String unit;
|
||||
|
||||
@ConstructorProperties({
|
||||
"max", "unit"
|
||||
})
|
||||
protected EmailQuota(int max, String unit) {
|
||||
this.max = max;
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the maximum size of the mailbox (in units)
|
||||
* @see #getUnit
|
||||
*/
|
||||
public int getMax() {
|
||||
return this.max;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the quota for this e-mail account
|
||||
*/
|
||||
public String getUnit() {
|
||||
return this.unit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(max, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
EmailQuota that = EmailQuota.class.cast(obj);
|
||||
return Objects.equal(this.max, that.max) && Objects.equal(this.unit, that.unit);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("").add("max", max).add("unit", unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -16,107 +16,145 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.glesys.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Represents an ip address used by a server.
|
||||
*
|
||||
* @author Adam Lowe
|
||||
* @see ServerCreated
|
||||
* @see Server
|
||||
* @see ServerDetails
|
||||
*/
|
||||
public class Ip {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromIp(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String ip;
|
||||
protected int version;
|
||||
protected double cost;
|
||||
protected String currency;
|
||||
|
||||
protected Builder version(int version) {
|
||||
this.version = version;
|
||||
return this;
|
||||
/**
|
||||
* @see Ip#getIp()
|
||||
*/
|
||||
public T ip(String ip) {
|
||||
this.ip = checkNotNull(ip, "ip");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder version4() {
|
||||
/**
|
||||
* @see Ip#getVersion()
|
||||
*/
|
||||
protected T version(int version) {
|
||||
this.version = version;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Ip#getVersion()
|
||||
*/
|
||||
public T version4() {
|
||||
return version(4);
|
||||
}
|
||||
|
||||
public Builder version6() {
|
||||
/**
|
||||
* @see Ip#getVersion()
|
||||
*/
|
||||
public T version6() {
|
||||
return version(6);
|
||||
}
|
||||
|
||||
public Builder ip(String ip) {
|
||||
this.ip = ip;
|
||||
return this;
|
||||
/**
|
||||
* @see Ip#getCost()
|
||||
*/
|
||||
public T cost(double cost) {
|
||||
this.cost = cost;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder cost(double cost) {
|
||||
this.cost = cost;
|
||||
return this;
|
||||
/**
|
||||
* @see Ip#getCurrency()
|
||||
*/
|
||||
public T currency(String currency) {
|
||||
this.currency = currency;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Ip build() {
|
||||
return new Ip(ip, version, cost);
|
||||
return new Ip(ip, version, cost, currency);
|
||||
}
|
||||
|
||||
public Builder fromIpCreated(Ip from) {
|
||||
return ip(from.getIp()).version(from.getVersion()).cost(from.getCost());
|
||||
public T fromIp(Ip in) {
|
||||
return this.ip(in.getIp()).version(in.getVersion()).cost(in.getCost());
|
||||
}
|
||||
}
|
||||
|
||||
@SerializedName("ipaddress")
|
||||
protected final String ip;
|
||||
protected final int version;
|
||||
protected final double cost;
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Ip(String ip, int version, double cost) {
|
||||
this.ip = ip;
|
||||
private final String ip;
|
||||
private final int version;
|
||||
private final double cost;
|
||||
private final String currency;
|
||||
|
||||
@ConstructorProperties({
|
||||
"ipaddress", "version", "cost", "currency"
|
||||
})
|
||||
protected Ip(String ip, int version, double cost, String currency) {
|
||||
this.ip = checkNotNull(ip, "ip");
|
||||
this.version = version;
|
||||
this.cost = cost;
|
||||
this.currency = checkNotNull(currency, "currency");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the IP version, ex. 4
|
||||
*/
|
||||
public int getVersion() {
|
||||
return version;
|
||||
public String getIp() {
|
||||
return this.ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ip address of the new server
|
||||
*/
|
||||
public String getIp() {
|
||||
return ip;
|
||||
public int getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cost of the ip address allocated to the new server
|
||||
* @see #getCurrency()
|
||||
*/
|
||||
public double getCost() {
|
||||
return cost;
|
||||
return this.cost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof Ip) {
|
||||
final Ip other = (Ip) object;
|
||||
return Objects.equal(ip, other.ip)
|
||||
&& Objects.equal(version, other.version)
|
||||
&& Objects.equal(cost, other.cost);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* @return the currency of the cost
|
||||
* @see #getCost()
|
||||
*/
|
||||
public String getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -124,9 +162,25 @@ public class Ip {
|
|||
return Objects.hashCode(ip, version, cost);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Ip that = Ip.class.cast(obj);
|
||||
return Objects.equal(this.ip, that.ip)
|
||||
&& Objects.equal(this.version, that.version)
|
||||
&& Objects.equal(this.cost, that.cost)
|
||||
&& Objects.equal(this.currency, that.currency);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("ip", ip).add("version", version).add("cost", cost).add("currency", currency);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[ip=%s, version=%d, cost=%f]",
|
||||
ip, version, cost);
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -16,187 +16,311 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.glesys.domain;
|
||||
|
||||
import java.util.Arrays;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.List;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
/**
|
||||
* Represents detailed information about an IP address.
|
||||
*/
|
||||
public class IpDetails {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromIpDetails(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String datacenter;
|
||||
protected String ipversion;
|
||||
protected int ipversion;
|
||||
protected String ptr;
|
||||
protected String platform;
|
||||
protected String address;
|
||||
protected String netmask;
|
||||
protected String broadcast;
|
||||
protected String gateway;
|
||||
protected List<String> nameservers;
|
||||
protected List<String> nameServers = ImmutableList.of();
|
||||
protected String serverId;
|
||||
protected Cost cost;
|
||||
protected boolean reserved;
|
||||
|
||||
public Builder datacenter(String datacenter) {
|
||||
this.datacenter = datacenter;
|
||||
return this;
|
||||
/**
|
||||
* @see IpDetails#getDatacenter()
|
||||
*/
|
||||
public T datacenter(String datacenter) {
|
||||
this.datacenter = checkNotNull(datacenter, "datacenter");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder ipversion(String ipversion) {
|
||||
protected T version(int ipversion) {
|
||||
this.ipversion = ipversion;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder ptr(String ptr) {
|
||||
this.ptr = ptr;
|
||||
return this;
|
||||
/*
|
||||
* @see IpDetails#getVersion()
|
||||
*/
|
||||
public T version4() {
|
||||
return version(4);
|
||||
}
|
||||
|
||||
public Builder platform(String platform) {
|
||||
this.platform = platform;
|
||||
return this;
|
||||
/*
|
||||
* @see IpDetails#getVersion()
|
||||
*/
|
||||
public T version6() {
|
||||
return version(6);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IpDetails#getPtr()
|
||||
*/
|
||||
public T ptr(String ptr) {
|
||||
this.ptr = checkNotNull(ptr, "ptr");
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IpDetails#getPlatform()
|
||||
*/
|
||||
public T platform(String platform) {
|
||||
this.platform = checkNotNull(platform, "platform");
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IpDetails#getAddress()
|
||||
*/
|
||||
public T address(String address) {
|
||||
this.address = address;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IpDetails#getNetmask()
|
||||
*/
|
||||
public T netmask(String netmask) {
|
||||
this.netmask = netmask;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IpDetails#getBroadcast()
|
||||
*/
|
||||
public T broadcast(String broadcast) {
|
||||
this.broadcast = broadcast;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IpDetails#getGateway()
|
||||
*/
|
||||
public T gateway(String gateway) {
|
||||
this.gateway = gateway;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IpDetails#getNameServers()
|
||||
*/
|
||||
public T nameServers(List<String> nameservers) {
|
||||
this.nameServers = ImmutableList.copyOf(checkNotNull(nameservers, "nameServers"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public T nameServers(String... in) {
|
||||
return nameServers(ImmutableList.copyOf(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IpDetails#getServerId()
|
||||
*/
|
||||
public T serverId(String serverId) {
|
||||
this.serverId = serverId;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IpDetails#getCost()
|
||||
*/
|
||||
public T cost(Cost cost) {
|
||||
this.cost = cost;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IpDetails#isReserved()
|
||||
*/
|
||||
public T reserved(boolean reserved) {
|
||||
this.reserved = reserved;
|
||||
return self();
|
||||
}
|
||||
|
||||
public IpDetails build() {
|
||||
return new IpDetails(datacenter, ipversion, ptr, platform,
|
||||
address, netmask, broadcast, gateway, nameservers);
|
||||
return new IpDetails(datacenter, ipversion, ptr, platform, address, netmask, broadcast, gateway, nameServers,
|
||||
serverId, cost, new GleSYSBoolean(reserved));
|
||||
}
|
||||
|
||||
public Builder address(String address) {
|
||||
this.address = address;
|
||||
return this;
|
||||
public T fromIpDetails(IpDetails in) {
|
||||
return this.datacenter(in.getDatacenter())
|
||||
.version(in.getVersion())
|
||||
.ptr(in.getPtr())
|
||||
.platform(in.getPlatform())
|
||||
.address(in.getAddress())
|
||||
.netmask(in.getNetmask())
|
||||
.broadcast(in.getBroadcast())
|
||||
.gateway(in.getGateway())
|
||||
.nameServers(in.getNameServers())
|
||||
.serverId(in.getServerId())
|
||||
.cost(in.getCost())
|
||||
.reserved(in.isReserved());
|
||||
}
|
||||
}
|
||||
|
||||
public Builder netmask(String netmask) {
|
||||
this.netmask = netmask;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder broadcast(String broadcast) {
|
||||
this.broadcast = broadcast;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder gateway(String gateway) {
|
||||
this.gateway = gateway;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder nameServers(String... nameServers) {
|
||||
this.nameservers = Arrays.asList(nameServers);
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
protected String datacenter;
|
||||
protected String ipversion;
|
||||
@SerializedName("PTR")
|
||||
protected String ptr;
|
||||
protected String platform;
|
||||
protected String address;
|
||||
protected String netmask;
|
||||
protected String broadcast;
|
||||
protected String gateway;
|
||||
protected List<String> nameservers;
|
||||
private final String datacenter;
|
||||
private final int version;
|
||||
private final String ptr;
|
||||
private final String platform;
|
||||
private final String address;
|
||||
private final String netmask;
|
||||
private final String broadcast;
|
||||
private final String gateway;
|
||||
private final List<String> nameServers;
|
||||
private final String serverId;
|
||||
private final Cost cost;
|
||||
private final boolean reserved;
|
||||
|
||||
public IpDetails(String datacenter, String ipversion, String ptr, String platform,
|
||||
@Nullable String address, @Nullable String netmask,
|
||||
@Nullable String broadcast, @Nullable String gateway,
|
||||
@Nullable List<String> nameservers) {
|
||||
this.datacenter = datacenter;
|
||||
this.ipversion = ipversion;
|
||||
this.ptr = ptr;
|
||||
this.platform = platform;
|
||||
@ConstructorProperties({
|
||||
"datacenter", "ipversion", "ptr", "platform", "ipaddress", "netmask", "broadcast", "gateway", "nameservers",
|
||||
"serverid", "cost", "reserved"
|
||||
})
|
||||
protected IpDetails(String datacenter, int version, String ptr, String platform, String address,
|
||||
@Nullable String netmask, @Nullable String broadcast, @Nullable String gateway,
|
||||
List<String> nameServers, @Nullable String serverId, Cost cost, GleSYSBoolean reserved) {
|
||||
this.datacenter = checkNotNull(datacenter, "datacenter");
|
||||
this.version = checkNotNull(version, "version");
|
||||
this.ptr = checkNotNull(ptr, "ptr");
|
||||
this.platform = checkNotNull(platform, "platform");
|
||||
this.address = address;
|
||||
this.netmask = netmask;
|
||||
this.broadcast = broadcast;
|
||||
this.gateway = gateway;
|
||||
this.nameservers = nameservers;
|
||||
this.nameServers = ImmutableList.copyOf(nameServers);
|
||||
this.serverId = serverId;
|
||||
this.cost = checkNotNull(cost, "cost");
|
||||
this.reserved = checkNotNull(reserved, "reserved").getValue();
|
||||
}
|
||||
|
||||
public String getDatacenter() {
|
||||
return datacenter;
|
||||
return this.datacenter;
|
||||
}
|
||||
|
||||
public String getIpversion() {
|
||||
return ipversion;
|
||||
/**
|
||||
* @return the IP version, ex. 4
|
||||
*/
|
||||
public int getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public String getPtr() {
|
||||
return ptr;
|
||||
return this.ptr;
|
||||
}
|
||||
|
||||
public String getPlatform() {
|
||||
return platform;
|
||||
return this.platform;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
return this.address;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getNetmask() {
|
||||
return netmask;
|
||||
return this.netmask;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getBroadcast() {
|
||||
return broadcast;
|
||||
return this.broadcast;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getGateway() {
|
||||
return gateway;
|
||||
return this.gateway;
|
||||
}
|
||||
|
||||
public List<String> getNameServers() {
|
||||
return nameservers;
|
||||
return this.nameServers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
@Nullable
|
||||
public String getServerId() {
|
||||
return serverId;
|
||||
}
|
||||
|
||||
IpDetails ipDetails = (IpDetails) o;
|
||||
public Cost getCost() {
|
||||
return cost;
|
||||
}
|
||||
|
||||
if (address != null ? !address.equals(ipDetails.address) : ipDetails.address != null) return false;
|
||||
if (broadcast != null ? !broadcast.equals(ipDetails.broadcast) : ipDetails.broadcast != null) return false;
|
||||
if (datacenter != null ? !datacenter.equals(ipDetails.datacenter) : ipDetails.datacenter != null) return false;
|
||||
if (gateway != null ? !gateway.equals(ipDetails.gateway) : ipDetails.gateway != null) return false;
|
||||
if (ipversion != null ? !ipversion.equals(ipDetails.ipversion) : ipDetails.ipversion != null) return false;
|
||||
if (netmask != null ? !netmask.equals(ipDetails.netmask) : ipDetails.netmask != null) return false;
|
||||
if (platform != null ? !platform.equals(ipDetails.platform) : ipDetails.platform != null) return false;
|
||||
if (ptr != null ? !ptr.equals(ipDetails.ptr) : ipDetails.ptr != null) return false;
|
||||
if (nameservers != null ? !nameservers.equals(ipDetails.nameservers) : ipDetails.nameservers != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
public boolean isReserved() {
|
||||
return reserved;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = datacenter != null ? datacenter.hashCode() : 0;
|
||||
result = 31 * result + (ipversion != null ? ipversion.hashCode() : 0);
|
||||
result = 31 * result + (ptr != null ? ptr.hashCode() : 0);
|
||||
result = 31 * result + (platform != null ? platform.hashCode() : 0);
|
||||
result = 31 * result + (address != null ? address.hashCode() : 0);
|
||||
result = 31 * result + (netmask != null ? netmask.hashCode() : 0);
|
||||
result = 31 * result + (broadcast != null ? broadcast.hashCode() : 0);
|
||||
result = 31 * result + (gateway != null ? gateway.hashCode() : 0);
|
||||
return result;
|
||||
return Objects.hashCode(datacenter, version, ptr, platform, address, netmask, broadcast, gateway, nameServers,
|
||||
serverId, cost, reserved);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
IpDetails that = IpDetails.class.cast(obj);
|
||||
return Objects.equal(this.datacenter, that.datacenter)
|
||||
&& Objects.equal(this.version, that.version)
|
||||
&& Objects.equal(this.ptr, that.ptr)
|
||||
&& Objects.equal(this.platform, that.platform)
|
||||
&& Objects.equal(this.address, that.address)
|
||||
&& Objects.equal(this.netmask, that.netmask)
|
||||
&& Objects.equal(this.broadcast, that.broadcast)
|
||||
&& Objects.equal(this.gateway, that.gateway)
|
||||
&& Objects.equal(this.nameServers, that.nameServers)
|
||||
&& Objects.equal(this.serverId, that.serverId)
|
||||
&& Objects.equal(this.cost, that.cost)
|
||||
&& Objects.equal(this.reserved, that.reserved);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("datacenter", datacenter).add("ipversion", version).add("ptr", ptr).add("platform", platform)
|
||||
.add("address", address).add("netmask", netmask).add("broadcast", broadcast).add("gateway", gateway)
|
||||
.add("nameServers", nameServers).add("serverId", serverId).add("cost", cost).add("reserved", reserved);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("IpDetails[datacenter=%s, ipversion=%s, platform=%s, PTR=%s, " +
|
||||
"address=%s, netmask=%s, broadcast=%s, gateway=%s",
|
||||
datacenter, ipversion, platform, ptr, address, netmask, broadcast, gateway);
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,9 +18,12 @@
|
|||
*/
|
||||
package org.jclouds.glesys.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Operating system template
|
||||
|
@ -28,73 +31,106 @@ import com.google.gson.annotations.SerializedName;
|
|||
* @author Adam Lowe
|
||||
* @see <a href= "https://customer.glesys.com/api.php?a=doc#server_templates" />
|
||||
*/
|
||||
public class OSTemplate implements Comparable<OSTemplate>{
|
||||
public class OSTemplate {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private String name;
|
||||
private int minDiskSize;
|
||||
private int minMemSize;
|
||||
private String os;
|
||||
private String platform;
|
||||
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromOSTemplate(this);
|
||||
}
|
||||
|
||||
public Builder minDiskSize(int minDiskSize) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String name;
|
||||
protected int minDiskSize;
|
||||
protected int minMemSize;
|
||||
protected String os;
|
||||
protected String platform;
|
||||
|
||||
/**
|
||||
* @see OSTemplate#getName()
|
||||
*/
|
||||
public T name(String name) {
|
||||
this.name = checkNotNull(name, "name");
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see OSTemplate#getMinDiskSize()
|
||||
*/
|
||||
public T minDiskSize(int minDiskSize) {
|
||||
this.minDiskSize = minDiskSize;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder minMemSize(int minMemSize) {
|
||||
/**
|
||||
* @see OSTemplate#getMinMemSize()
|
||||
*/
|
||||
public T minMemSize(int minMemSize) {
|
||||
this.minMemSize = minMemSize;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder os(String os) {
|
||||
this.os = os;
|
||||
return this;
|
||||
/**
|
||||
* @see OSTemplate#getOs()
|
||||
*/
|
||||
public T os(String os) {
|
||||
this.os = checkNotNull(os, "os");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder platform(String platform) {
|
||||
this.platform = platform;
|
||||
return this;
|
||||
/**
|
||||
* @see OSTemplate#getPlatform()
|
||||
*/
|
||||
public T platform(String platform) {
|
||||
this.platform = checkNotNull(platform, "platform");
|
||||
return self();
|
||||
}
|
||||
|
||||
public OSTemplate build() {
|
||||
return new OSTemplate(name, minDiskSize, minMemSize, os, platform);
|
||||
}
|
||||
|
||||
public Builder fromTemplate(OSTemplate in) {
|
||||
return name(in.getName()).minDiskSize(in.getMinDiskSize()).minMemSize(in.getMinMemSize()).os(in.getOs()).platform(in.getPlatform());
|
||||
public T fromOSTemplate(OSTemplate in) {
|
||||
return this.name(in.getName())
|
||||
.minDiskSize(in.getMinDiskSize())
|
||||
.minMemSize(in.getMinMemSize())
|
||||
.os(in.getOs())
|
||||
.platform(in.getPlatform());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final String name;
|
||||
@SerializedName("minimumdisksize")
|
||||
private final int minDiskSize;
|
||||
@SerializedName("minimummemorysize")
|
||||
private final int minMemSize;
|
||||
@SerializedName("operatingsystem")
|
||||
private final String os;
|
||||
private final String platform;
|
||||
|
||||
public OSTemplate(String name, int minDiskSize, int minMemSize, String os, String platform) {
|
||||
this.name = name;
|
||||
@ConstructorProperties({
|
||||
"name", "minimumdisksize", "minimummemorysize", "operatingsystem", "platform"
|
||||
})
|
||||
protected OSTemplate(String name, int minDiskSize, int minMemSize, String os, String platform) {
|
||||
this.name = checkNotNull(name, "name");
|
||||
this.minDiskSize = minDiskSize;
|
||||
this.minMemSize = minMemSize;
|
||||
this.os = os;
|
||||
this.platform = platform;
|
||||
this.os = checkNotNull(os, "os");
|
||||
this.platform = checkNotNull(platform, "platform");
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -102,7 +138,7 @@ public class OSTemplate implements Comparable<OSTemplate>{
|
|||
* @see org.jclouds.glesys.domain.AllowedArgumentsForCreateServer#getDiskSizesInGB()
|
||||
*/
|
||||
public int getMinDiskSize() {
|
||||
return minDiskSize;
|
||||
return this.minDiskSize;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -110,35 +146,21 @@ public class OSTemplate implements Comparable<OSTemplate>{
|
|||
* @see org.jclouds.glesys.domain.AllowedArgumentsForCreateServer#getMemorySizesInMB()
|
||||
*/
|
||||
public int getMinMemSize() {
|
||||
return minMemSize;
|
||||
return this.minMemSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the operating system type ex. "linux"
|
||||
*/
|
||||
public String getOs() {
|
||||
return os;
|
||||
return this.os;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the platform this template is available in, ex. "Xen"
|
||||
*/
|
||||
public String getPlatform() {
|
||||
return platform;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof OSTemplate) {
|
||||
final OSTemplate other = (OSTemplate) object;
|
||||
return Objects.equal(name, other.name)
|
||||
&& Objects.equal(platform, other.platform);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return this.platform;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -147,13 +169,22 @@ public class OSTemplate implements Comparable<OSTemplate>{
|
|||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[name=%s, min_disk_size=%d, min_mem_size=%d, os=%s, platform=%s]",
|
||||
name, minDiskSize, minMemSize, os, platform);
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
OSTemplate that = OSTemplate.class.cast(obj);
|
||||
return Objects.equal(this.name, that.name)
|
||||
&& Objects.equal(this.platform, that.platform);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("name", name).add("minDiskSize", minDiskSize).add("minMemSize", minMemSize).add("os", os).add("platform", platform);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(OSTemplate arg0) {
|
||||
return Ordering.usingToString().compare(this, arg0);
|
||||
public String toString() {
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,7 +18,12 @@
|
|||
*/
|
||||
package org.jclouds.glesys.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Detailed information on usage
|
||||
|
@ -26,38 +31,60 @@ import com.google.common.base.Objects;
|
|||
* @author Adam Lowe
|
||||
* @see ServerStatus
|
||||
*/
|
||||
|
||||
public class ResourceUsage {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private double usage;
|
||||
private double max;
|
||||
private String unit;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromResourceUsage(this);
|
||||
}
|
||||
|
||||
public Builder usage(double usage) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected double usage;
|
||||
protected double max;
|
||||
protected String unit;
|
||||
|
||||
/**
|
||||
* @see ResourceUsage#getUsage()
|
||||
*/
|
||||
public T usage(double usage) {
|
||||
this.usage = usage;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder max(double max) {
|
||||
/**
|
||||
* @see ResourceUsage#getMax()
|
||||
*/
|
||||
public T max(double max) {
|
||||
this.max = max;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder unit(String unit) {
|
||||
this.unit = unit;
|
||||
return this;
|
||||
/**
|
||||
* @see ResourceUsage#getUnit()
|
||||
*/
|
||||
public T unit(String unit) {
|
||||
this.unit = checkNotNull(unit, "unit");
|
||||
return self();
|
||||
}
|
||||
|
||||
public ResourceUsage build() {
|
||||
return new ResourceUsage(usage, max, unit);
|
||||
}
|
||||
|
||||
public Builder fromCpu(ResourceUsage in) {
|
||||
return usage(in.getUsage()).max(in.getMax()).unit(in.getUnit());
|
||||
public T fromResourceUsage(ResourceUsage in) {
|
||||
return this.usage(in.getUsage()).max(in.getMax()).unit(in.getUnit());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,46 +92,34 @@ public class ResourceUsage {
|
|||
private final double max;
|
||||
private final String unit;
|
||||
|
||||
public ResourceUsage(double usage, double max, String unit) {
|
||||
@ConstructorProperties({
|
||||
"usage", "max", "unit"
|
||||
})
|
||||
protected ResourceUsage(double usage, double max, String unit) {
|
||||
this.usage = usage;
|
||||
this.max = max;
|
||||
this.unit = unit;
|
||||
this.unit = checkNotNull(unit, "unit");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the usage in #unit
|
||||
*/
|
||||
public double getUsage() {
|
||||
return usage;
|
||||
return this.usage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the max usage in #unit
|
||||
*/
|
||||
public double getMax() {
|
||||
return max;
|
||||
return this.max;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the unit used
|
||||
*/
|
||||
public String getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof ResourceUsage) {
|
||||
ResourceUsage other = (ResourceUsage) object;
|
||||
return Objects.equal(usage, other.usage)
|
||||
&& Objects.equal(max, other.max)
|
||||
&& Objects.equal(unit, other.unit);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return this.unit;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -112,9 +127,23 @@ public class ResourceUsage {
|
|||
return Objects.hashCode(usage, max, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ResourceUsage that = ResourceUsage.class.cast(obj);
|
||||
return Objects.equal(this.usage, that.usage)
|
||||
&& Objects.equal(this.max, that.max)
|
||||
&& Objects.equal(this.unit, that.unit);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("").add("usage", usage).add("max", max).add("unit", unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[usage=%f, max=%f, unit=%s]",
|
||||
usage, max, unit);
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,9 +20,11 @@ package org.jclouds.glesys.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Listing of a server.
|
||||
|
@ -30,8 +32,10 @@ import com.google.gson.annotations.SerializedName;
|
|||
* @author Adrian Cole
|
||||
* @see <a href= "https://customer.glesys.com/api.php?a=doc#server_list" />
|
||||
*/
|
||||
public class Server implements Comparable<Server> {
|
||||
public class Server {
|
||||
|
||||
/**
|
||||
*/
|
||||
public static enum State {
|
||||
|
||||
RUNNING, LOCKED, STOPPED, UNRECOGNIZED;
|
||||
|
@ -54,52 +58,79 @@ public class Server implements Comparable<Server> {
|
|||
}
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromServer(this);
|
||||
}
|
||||
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String id;
|
||||
protected String hostname;
|
||||
protected String datacenter;
|
||||
protected String platform;
|
||||
|
||||
public Builder id(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
/**
|
||||
* @see Server#getId()
|
||||
*/
|
||||
public T id(String id) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder hostname(String hostname) {
|
||||
this.hostname = hostname;
|
||||
return this;
|
||||
/**
|
||||
* @see Server#getHostname()
|
||||
*/
|
||||
public T hostname(String hostname) {
|
||||
this.hostname = checkNotNull(hostname, "hostname");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder datacenter(String datacenter) {
|
||||
this.datacenter = datacenter;
|
||||
return this;
|
||||
/**
|
||||
* @see Server#getDatacenter()
|
||||
*/
|
||||
public T datacenter(String datacenter) {
|
||||
this.datacenter = checkNotNull(datacenter, "datacenter");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder platform(String platform) {
|
||||
this.platform = platform;
|
||||
return this;
|
||||
/**
|
||||
* @see Server#getPlatform()
|
||||
*/
|
||||
public T platform(String platform) {
|
||||
this.platform = checkNotNull(platform, "platform");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Server build() {
|
||||
return new Server(id, hostname, datacenter, platform);
|
||||
}
|
||||
|
||||
public Builder fromServer(Server in) {
|
||||
return datacenter(in.getDatacenter()).platform(in.getPlatform()).hostname(in.getHostname()).id(in.getId());
|
||||
public T fromServer(Server in) {
|
||||
return this.id(in.getId()).hostname(in.getHostname()).datacenter(in.getDatacenter()).platform(in.getPlatform());
|
||||
}
|
||||
}
|
||||
|
||||
@SerializedName("serverid")
|
||||
protected final String id;
|
||||
protected final String hostname;
|
||||
protected final String datacenter;
|
||||
protected final String platform;
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Server(String id, String hostname, String datacenter, String platform) {
|
||||
private final String id;
|
||||
private final String hostname;
|
||||
private final String datacenter;
|
||||
private final String platform;
|
||||
|
||||
@ConstructorProperties({
|
||||
"serverid", "hostname", "datacenter", "platform"
|
||||
})
|
||||
protected Server(String id, String hostname, String datacenter, String platform) {
|
||||
this.id = checkNotNull(id, "id");
|
||||
this.hostname = checkNotNull(hostname, "hostname");
|
||||
this.datacenter = checkNotNull(datacenter, "datacenter");
|
||||
|
@ -110,45 +141,28 @@ public class Server implements Comparable<Server> {
|
|||
* @return the generated id of the server
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the hostname of the server
|
||||
*/
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
return this.hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return platform running the server (ex. {@code OpenVZ})
|
||||
*/
|
||||
public String getPlatform() {
|
||||
return platform;
|
||||
public String getDatacenter() {
|
||||
return this.datacenter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the datacenter the server exists in (ex. {@code Falkenberg})
|
||||
*/
|
||||
public String getDatacenter() {
|
||||
return datacenter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Server other) {
|
||||
return id.compareTo(other.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof Server) {
|
||||
return Objects.equal(id, ((Server) object).id);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
public String getPlatform() {
|
||||
return this.platform;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -156,9 +170,22 @@ public class Server implements Comparable<Server> {
|
|||
return Objects.hashCode(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
Server that = Server.class.cast(obj);
|
||||
return Objects.equal(this.id, that.id);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("").add("id", id).add("hostname", hostname).add("datacenter", datacenter)
|
||||
.add("platform", platform);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[id=%s, hostname=%s, datacenter=%s, platform=%s]", id, hostname, datacenter, platform);
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -20,10 +20,13 @@ package org.jclouds.glesys.domain;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* Detailed information about a server such as cpuCores, hardware configuration
|
||||
|
@ -33,208 +36,220 @@ import com.google.gson.annotations.SerializedName;
|
|||
* @see <a href= "https://customer.glesys.com/api.php?a=doc#server_details" />
|
||||
*/
|
||||
public class ServerDetails extends Server {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder extends Server.Builder {
|
||||
private Server.State state;
|
||||
private String description;
|
||||
private String templateName;
|
||||
private int cpuCores;
|
||||
private int memorySizeMB;
|
||||
private int diskSizeGB;
|
||||
private int transferGB;
|
||||
private Cost cost;
|
||||
private Set<Ip> ips = ImmutableSet.of();
|
||||
|
||||
public Builder state(Server.State state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromServerDetails(this);
|
||||
}
|
||||
|
||||
public Builder description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
public static abstract class Builder<T extends Builder<T>> extends Server.Builder<T> {
|
||||
protected Server.State state;
|
||||
protected String description;
|
||||
protected String templateName;
|
||||
protected int cpuCores;
|
||||
protected int memorySizeMB;
|
||||
protected int diskSizeGB;
|
||||
protected int transferGB;
|
||||
protected Cost cost;
|
||||
protected Set<Ip> ips = ImmutableSet.of();
|
||||
|
||||
/**
|
||||
* @see ServerDetails#getState()
|
||||
*/
|
||||
public T state(Server.State state) {
|
||||
this.state = checkNotNull(state, "state");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder templateName(String templateName) {
|
||||
this.templateName = templateName;
|
||||
return this;
|
||||
/**
|
||||
* @see ServerDetails#getDescription()
|
||||
*/
|
||||
public T description(String description) {
|
||||
this.description = checkNotNull(description, "description");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder cpuCores(int cpuCores) {
|
||||
/**
|
||||
* @see ServerDetails#getTemplateName()
|
||||
*/
|
||||
public T templateName(String templateName) {
|
||||
this.templateName = checkNotNull(templateName, "templateName");
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ServerDetails#getCpuCores()
|
||||
*/
|
||||
public T cpuCores(int cpuCores) {
|
||||
this.cpuCores = cpuCores;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder memorySizeMB(int memorySizeMB) {
|
||||
/**
|
||||
* @see ServerDetails#getMemorySizeMB()
|
||||
*/
|
||||
public T memorySizeMB(int memorySizeMB) {
|
||||
this.memorySizeMB = memorySizeMB;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder diskSizeGB(int diskSizeGB) {
|
||||
/**
|
||||
* @see ServerDetails#getDiskSizeGB()
|
||||
*/
|
||||
public T diskSizeGB(int diskSizeGB) {
|
||||
this.diskSizeGB = diskSizeGB;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder transferGB(int transferGB) {
|
||||
/**
|
||||
* @see ServerDetails#getTransferGB()
|
||||
*/
|
||||
public T transferGB(int transferGB) {
|
||||
this.transferGB = transferGB;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder cost(Cost cost) {
|
||||
this.cost = cost;
|
||||
return this;
|
||||
/**
|
||||
* @see ServerDetails#getCost()
|
||||
*/
|
||||
public T cost(Cost cost) {
|
||||
this.cost = checkNotNull(cost, "cost");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder ips(Ip... ips) {
|
||||
return ips(ImmutableSet.copyOf(ips));
|
||||
/**
|
||||
* @see ServerDetails#getIps()
|
||||
*/
|
||||
public T ips(Set<Ip> ips) {
|
||||
this.ips = ImmutableSet.copyOf(checkNotNull(ips, "ips"));
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder ips(Iterable<Ip> ips) {
|
||||
this.ips = ImmutableSet.copyOf(ips);
|
||||
return this;
|
||||
public T ips(Ip... in) {
|
||||
return ips(ImmutableSet.copyOf(in));
|
||||
}
|
||||
|
||||
public ServerDetails build() {
|
||||
return new ServerDetails(id, hostname, datacenter, platform, state, templateName, description, cpuCores,
|
||||
memorySizeMB, diskSizeGB, transferGB, cost, ips);
|
||||
return new ServerDetails(id, hostname, datacenter, platform, state, description, templateName, cpuCores, memorySizeMB, diskSizeGB, transferGB, cost, ips);
|
||||
}
|
||||
|
||||
public Builder fromServerDetails(ServerDetails in) {
|
||||
return fromServer(in).templateName(in.getTemplateName()).state(in.getState()).memorySizeMB(in.getMemorySizeMB())
|
||||
.diskSizeGB(in.getDiskSizeGB()).cpuCores(in.getCpuCores()).cost(in.getCost())
|
||||
.transferGB(in.getTransferGB()).description(in.getDescription()).ips(in.getIps());
|
||||
public T fromServerDetails(ServerDetails in) {
|
||||
return super.fromServer(in)
|
||||
.state(in.getState())
|
||||
.description(in.getDescription())
|
||||
.templateName(in.getTemplateName())
|
||||
.cpuCores(in.getCpuCores())
|
||||
.memorySizeMB(in.getMemorySizeMB())
|
||||
.diskSizeGB(in.getDiskSizeGB())
|
||||
.transferGB(in.getTransferGB())
|
||||
.cost(in.getCost())
|
||||
.ips(in.getIps());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
public Builder id(String id) {
|
||||
return Builder.class.cast(super.id(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder hostname(String hostname) {
|
||||
return Builder.class.cast(super.hostname(hostname));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder datacenter(String datacenter) {
|
||||
return Builder.class.cast(super.datacenter(datacenter));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder platform(String platform) {
|
||||
return Builder.class.cast(super.platform(platform));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder fromServer(Server in) {
|
||||
return Builder.class.cast(super.fromServer(in));
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final Server.State state;
|
||||
private final String description;
|
||||
@SerializedName("templatename")
|
||||
private final String templateName;
|
||||
@SerializedName("cpucores")
|
||||
private final int cpuCores;
|
||||
@SerializedName("memorysize")
|
||||
private final int memorySizeMB;
|
||||
@SerializedName("disksize")
|
||||
private final int diskSizeGB;
|
||||
@SerializedName("transfer")
|
||||
private final int transferGB;
|
||||
private final Cost cost;
|
||||
@SerializedName("iplist")
|
||||
private final Set<Ip> ips;
|
||||
|
||||
public ServerDetails(String id, String hostname, String datacenter, String platform, Server.State state,
|
||||
String templateName, String description, int cpuCores, int memorySizeMB, int diskSizeGB, int transferGB,
|
||||
Cost cost, Set<Ip> ips) {
|
||||
@ConstructorProperties({
|
||||
"serverid", "hostname", "datacenter", "platform", "state", "description", "templatename", "cpucores", "memorysize", "disksize", "transfer", "cost", "iplist"
|
||||
})
|
||||
protected ServerDetails(String id, String hostname, String datacenter, String platform, @Nullable Server.State state, @Nullable String description, String templateName, int cpuCores, int memorySizeMB, int diskSizeGB, int transferGB, Cost cost, @Nullable Set<Ip> ips) {
|
||||
super(id, hostname, datacenter, platform);
|
||||
this.state = state;
|
||||
this.templateName = checkNotNull(templateName, "template");
|
||||
this.description = description;
|
||||
this.templateName = checkNotNull(templateName, "templateName");
|
||||
this.cpuCores = cpuCores;
|
||||
this.memorySizeMB = memorySizeMB;
|
||||
this.diskSizeGB = diskSizeGB;
|
||||
this.transferGB = transferGB;
|
||||
this.cost = checkNotNull(cost, "cost");
|
||||
this.ips = ImmutableSet.<Ip> copyOf(ips);
|
||||
this.ips = ips == null ? ImmutableSet.<Ip>of() : ImmutableSet.copyOf(checkNotNull(ips, "ips"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the state of the server (e.g. "running")
|
||||
*/
|
||||
public Server.State getState() {
|
||||
return state;
|
||||
return this.state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the user-specified description of the server
|
||||
*/
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return number of cores on the server
|
||||
*/
|
||||
public int getCpuCores() {
|
||||
return cpuCores;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the disk of the server in GB
|
||||
*/
|
||||
public int getDiskSizeGB() {
|
||||
return diskSizeGB;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the memory of the server in MB
|
||||
*/
|
||||
public int getMemorySizeMB() {
|
||||
return memorySizeMB;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the transfer of the server
|
||||
*/
|
||||
public int getTransferGB() {
|
||||
return transferGB;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return details of the cost of the server
|
||||
*/
|
||||
public Cost getCost() {
|
||||
return cost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ip addresses assigned to the server
|
||||
*/
|
||||
public Set<Ip> getIps() {
|
||||
return ips;
|
||||
return this.description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the template used to create the server
|
||||
*/
|
||||
public String getTemplateName() {
|
||||
return templateName;
|
||||
return this.templateName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String
|
||||
.format(
|
||||
"[id=%s, hostname=%s, datacenter=%s, platform=%s, templateName=%s, state=%s, description=%s, cpuCores=%d, memorySizeMB=%d, diskSizeGB=%d, transferGB=%d, cost=%s, ips=%s]",
|
||||
id, hostname, datacenter, platform, templateName, state, description, cpuCores, memorySizeMB,
|
||||
diskSizeGB, transferGB, cost, ips);
|
||||
/**
|
||||
* @return number of cores on the server
|
||||
*/
|
||||
public int getCpuCores() {
|
||||
return this.cpuCores;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the memory of the server in MB
|
||||
*/
|
||||
public int getMemorySizeMB() {
|
||||
return this.memorySizeMB;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the disk of the server in GB
|
||||
*/
|
||||
public int getDiskSizeGB() {
|
||||
return this.diskSizeGB;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the transfer of the server
|
||||
*/
|
||||
public int getTransferGB() {
|
||||
return this.transferGB;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return details of the cost of the server
|
||||
*/
|
||||
public Cost getCost() {
|
||||
return this.cost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ip addresses assigned to the server
|
||||
*/
|
||||
public Set<Ip> getIps() {
|
||||
return this.ips;
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return super.string().add("state", state).add("description", description).add("templateName", templateName)
|
||||
.add("cpuCores", cpuCores).add("memorySizeMB", memorySizeMB).add("diskSizeGB", diskSizeGB)
|
||||
.add("transferGB", transferGB).add("cost", cost).add("ips", ips);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,7 +18,10 @@
|
|||
*/
|
||||
package org.jclouds.glesys.domain;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Detailed information about an OpenVZ server's limits
|
||||
|
@ -27,45 +30,82 @@ import com.google.common.base.Objects;
|
|||
* @see <a href= "https://customer.glesys.com/api.php?a=doc#server_limits" />
|
||||
*/
|
||||
public class ServerLimit {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private int held;
|
||||
private int maxHeld;
|
||||
private int barrier;
|
||||
private int limit;
|
||||
private int failCount;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromServerLimit(this);
|
||||
}
|
||||
|
||||
public Builder held(int held) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected long held;
|
||||
protected long maxHeld;
|
||||
protected long barrier;
|
||||
protected long limit;
|
||||
protected long failCount;
|
||||
|
||||
/**
|
||||
* @see ServerLimit#getHeld()
|
||||
*/
|
||||
public T held(long held) {
|
||||
this.held = held;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder maxHeld(int maxHeld) {
|
||||
/**
|
||||
* @see ServerLimit#getMaxHeld()
|
||||
*/
|
||||
public T maxHeld(long maxHeld) {
|
||||
this.maxHeld = maxHeld;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder barrier(int barrier) {
|
||||
/**
|
||||
* @see ServerLimit#getBarrier()
|
||||
*/
|
||||
public T barrier(long barrier) {
|
||||
this.barrier = barrier;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder limit(int limit) {
|
||||
/**
|
||||
* @see ServerLimit#getLimit()
|
||||
*/
|
||||
public T limit(long limit) {
|
||||
this.limit = limit;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder failCount(int failCount) {
|
||||
/**
|
||||
* @see ServerLimit#getFailCount()
|
||||
*/
|
||||
public T failCount(long failCount) {
|
||||
this.failCount = failCount;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public ServerLimit build() {
|
||||
return new ServerLimit(held, maxHeld, barrier, limit, failCount);
|
||||
}
|
||||
|
||||
public T fromServerLimit(ServerLimit in) {
|
||||
return this.held(in.getHeld())
|
||||
.maxHeld(in.getMaxHeld())
|
||||
.barrier(in.getBarrier())
|
||||
.limit(in.getLimit())
|
||||
.failCount(in.getFailCount());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final long held;
|
||||
|
@ -74,7 +114,10 @@ public class ServerLimit {
|
|||
private final long limit;
|
||||
private final long failCount;
|
||||
|
||||
public ServerLimit(long held, long maxHeld, long barrier, long limit, long failCount) {
|
||||
@ConstructorProperties({
|
||||
"held", "maxHeld", "barrier", "limit", "failCount"
|
||||
})
|
||||
protected ServerLimit(long held, long maxHeld, long barrier, long limit, long failCount) {
|
||||
this.held = held;
|
||||
this.maxHeld = maxHeld;
|
||||
this.barrier = barrier;
|
||||
|
@ -83,40 +126,23 @@ public class ServerLimit {
|
|||
}
|
||||
|
||||
public long getHeld() {
|
||||
return held;
|
||||
return this.held;
|
||||
}
|
||||
|
||||
public long getMaxHeld() {
|
||||
return maxHeld;
|
||||
return this.maxHeld;
|
||||
}
|
||||
|
||||
public long getBarrier() {
|
||||
return barrier;
|
||||
return this.barrier;
|
||||
}
|
||||
|
||||
public long getLimit() {
|
||||
return limit;
|
||||
return this.limit;
|
||||
}
|
||||
|
||||
public long getFailCount() {
|
||||
return failCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof ServerLimit) {
|
||||
final ServerLimit other = (ServerLimit) object;
|
||||
return Objects.equal(held, other.held)
|
||||
&& Objects.equal(maxHeld, other.maxHeld)
|
||||
&& Objects.equal(barrier, other.barrier)
|
||||
&& Objects.equal(limit, other.limit)
|
||||
&& Objects.equal(failCount, other.failCount);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return this.failCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -124,8 +150,26 @@ public class ServerLimit {
|
|||
return Objects.hashCode(held, maxHeld, barrier, limit, failCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ServerLimit that = ServerLimit.class.cast(obj);
|
||||
return Objects.equal(this.held, that.held)
|
||||
&& Objects.equal(this.maxHeld, that.maxHeld)
|
||||
&& Objects.equal(this.barrier, that.barrier)
|
||||
&& Objects.equal(this.limit, that.limit)
|
||||
&& Objects.equal(this.failCount, that.failCount);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("").add("held", held).add("maxHeld", maxHeld).add("barrier", barrier)
|
||||
.add("limit", limit).add("failCount", failCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[held=%d, maxHeld=%d, barrier=%d, limit=%d, failCount=%d]", held, maxHeld, barrier, limit, failCount);
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,92 +18,129 @@
|
|||
*/
|
||||
package org.jclouds.glesys.domain;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Objects.toStringHelper;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class ServerSpec
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class ServerSpec {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return Builder.fromServerSpecification(this);
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromServerSpec(this);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
protected String datacenter;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected String platform;
|
||||
protected String templateName;
|
||||
protected int diskSizeGB;
|
||||
protected String datacenter;
|
||||
protected int memorySizeMB;
|
||||
protected int diskSizeGB;
|
||||
protected String templateName;
|
||||
protected int cpuCores;
|
||||
protected int transferGB;
|
||||
|
||||
public Builder datacenter(String datacenter) {
|
||||
this.datacenter = datacenter;
|
||||
return this;
|
||||
/**
|
||||
* @see ServerSpec#getPlatform()
|
||||
*/
|
||||
public T platform(String platform) {
|
||||
this.platform = checkNotNull(platform, "platform");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder platform(String platform) {
|
||||
this.platform = platform;
|
||||
return this;
|
||||
/**
|
||||
* @see ServerSpec#getDatacenter()
|
||||
*/
|
||||
public T datacenter(String datacenter) {
|
||||
this.datacenter = checkNotNull(datacenter, "datacenter");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder templateName(String templateName) {
|
||||
this.templateName = templateName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder diskSizeGB(int diskSizeGB) {
|
||||
this.diskSizeGB = diskSizeGB;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder memorySizeMB(int memorySizeMB) {
|
||||
/**
|
||||
* @see ServerSpec#getMemorySizeMB()
|
||||
*/
|
||||
public T memorySizeMB(int memorySizeMB) {
|
||||
this.memorySizeMB = memorySizeMB;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder cpuCores(int cpuCores) {
|
||||
/**
|
||||
* @see ServerSpec#getDiskSizeGB()
|
||||
*/
|
||||
public T diskSizeGB(int diskSizeGB) {
|
||||
this.diskSizeGB = diskSizeGB;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ServerSpec#getTemplateName()
|
||||
*/
|
||||
public T templateName(String templateName) {
|
||||
this.templateName = checkNotNull(templateName, "templateName");
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ServerSpec#getCpuCores()
|
||||
*/
|
||||
public T cpuCores(int cpuCores) {
|
||||
this.cpuCores = cpuCores;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder transferGB(int transferGB) {
|
||||
/**
|
||||
* @see ServerSpec#getTransferGB()
|
||||
*/
|
||||
public T transferGB(int transferGB) {
|
||||
this.transferGB = transferGB;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public ServerSpec build() {
|
||||
return new ServerSpec(platform, datacenter, memorySizeMB, diskSizeGB, templateName, cpuCores, transferGB);
|
||||
}
|
||||
|
||||
public static Builder fromServerSpecification(ServerSpec in) {
|
||||
return new Builder().platform(in.getPlatform()).datacenter(in.getDatacenter())
|
||||
.memorySizeMB(in.getMemorySizeMB()).diskSizeGB(in.getDiskSizeGB()).templateName(in.getTemplateName())
|
||||
.cpuCores(in.getCpuCores()).transferGB(in.getTransferGB());
|
||||
public T fromServerSpec(ServerSpec in) {
|
||||
return this.platform(in.getPlatform())
|
||||
.datacenter(in.getDatacenter())
|
||||
.memorySizeMB(in.getMemorySizeMB())
|
||||
.diskSizeGB(in.getDiskSizeGB())
|
||||
.templateName(in.getTemplateName())
|
||||
.cpuCores(in.getCpuCores())
|
||||
.transferGB(in.getTransferGB());
|
||||
}
|
||||
}
|
||||
|
||||
protected final String platform;
|
||||
protected final String datacenter;
|
||||
protected final int memorySizeMB;
|
||||
protected final int diskSizeGB;
|
||||
protected final String templateName;
|
||||
protected final int cpuCores;
|
||||
protected final int transferGB;
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
protected ServerSpec(String platform, String datacenter, int memorySizeMB, int diskSizeGB, String templateName,
|
||||
int cpuCores, int transferGB) {
|
||||
private final String platform;
|
||||
private final String datacenter;
|
||||
private final int memorySizeMB;
|
||||
private final int diskSizeGB;
|
||||
private final String templateName;
|
||||
private final int cpuCores;
|
||||
private final int transferGB;
|
||||
|
||||
@ConstructorProperties({
|
||||
"platform", "datacenter", "memorySizeMB", "diskSizeGB", "templateName", "cpuCores", "transferGB"
|
||||
})
|
||||
protected ServerSpec(String platform, String datacenter, int memorySizeMB, int diskSizeGB, String templateName, int cpuCores, int transferGB) {
|
||||
this.platform = checkNotNull(platform, "platform");
|
||||
this.datacenter = checkNotNull(datacenter, "datacenter");
|
||||
this.memorySizeMB = memorySizeMB;
|
||||
|
@ -116,66 +153,50 @@ public class ServerSpec {
|
|||
/**
|
||||
* @return the data center to create the new server in
|
||||
*/
|
||||
public String getDatacenter() {
|
||||
return datacenter;
|
||||
public String getPlatform() {
|
||||
return this.platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the platform to use (i.e. "Xen" or "OpenVZ")
|
||||
*/
|
||||
public String getPlatform() {
|
||||
return platform;
|
||||
public String getDatacenter() {
|
||||
return this.datacenter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the os template to use to create the new server
|
||||
*/
|
||||
public String getTemplateName() {
|
||||
return templateName;
|
||||
public int getMemorySizeMB() {
|
||||
return this.memorySizeMB;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the amount of disk space, in GB, to allocate
|
||||
*/
|
||||
public int getDiskSizeGB() {
|
||||
return diskSizeGB;
|
||||
return this.diskSizeGB;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the memory, in MB, to allocate
|
||||
*/
|
||||
public int getMemorySizeMB() {
|
||||
return memorySizeMB;
|
||||
public String getTemplateName() {
|
||||
return this.templateName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of CPU cores to allocate
|
||||
*/
|
||||
public int getCpuCores() {
|
||||
return cpuCores;
|
||||
return this.cpuCores;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bandwidth of in GB
|
||||
*/
|
||||
public int getTransferGB() {
|
||||
return transferGB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof ServerSpec) {
|
||||
final ServerSpec that = ServerSpec.class.cast(object);
|
||||
return equal(platform, that.platform) && equal(datacenter, that.datacenter)
|
||||
&& equal(memorySizeMB, that.memorySizeMB) && equal(diskSizeGB, that.diskSizeGB)
|
||||
&& equal(templateName, that.templateName) && equal(cpuCores, that.cpuCores)
|
||||
&& equal(transferGB, that.transferGB);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return this.transferGB;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -183,10 +204,28 @@ public class ServerSpec {
|
|||
return Objects.hashCode(platform, datacenter, memorySizeMB, diskSizeGB, templateName, cpuCores, transferGB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ServerSpec that = ServerSpec.class.cast(obj);
|
||||
return Objects.equal(this.platform, that.platform)
|
||||
&& Objects.equal(this.datacenter, that.datacenter)
|
||||
&& Objects.equal(this.memorySizeMB, that.memorySizeMB)
|
||||
&& Objects.equal(this.diskSizeGB, that.diskSizeGB)
|
||||
&& Objects.equal(this.templateName, that.templateName)
|
||||
&& Objects.equal(this.cpuCores, that.cpuCores)
|
||||
&& Objects.equal(this.transferGB, that.transferGB);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("").add("platform", platform).add("datacenter", datacenter)
|
||||
.add("memorySizeMB", memorySizeMB).add("diskSizeGB", diskSizeGB).add("templateName", templateName)
|
||||
.add("cpuCores", cpuCores).add("transferGB", transferGB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toStringHelper("").add("platform", platform).add("datacenter", datacenter)
|
||||
.add("templateName", templateName).add("cpuCores", cpuCores).add("memorySizeMB", memorySizeMB)
|
||||
.add("diskSizeGB", diskSizeGB).add("transferGB", transferGB).toString();
|
||||
return string().toString();
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,7 +18,14 @@
|
|||
*/
|
||||
package org.jclouds.glesys.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Detailed information server status including hardware usage (cpu, memory and disk), bandwidth and up-time.
|
||||
|
@ -26,51 +33,78 @@ import com.google.common.base.Objects;
|
|||
* @author Adam Lowe
|
||||
* @see <a href= "https://customer.glesys.com/api.php?a=doc#server_status" />
|
||||
*/
|
||||
|
||||
public class ServerStatus {
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private Server.State state;
|
||||
private ResourceUsage cpu;
|
||||
private ResourceUsage memory;
|
||||
private ResourceUsage disk;
|
||||
private ServerUptime uptime;
|
||||
|
||||
public Builder state(Server.State state) {
|
||||
this.state = state;
|
||||
return this;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromServerStatus(this);
|
||||
}
|
||||
|
||||
public Builder cpu(ResourceUsage cpu) {
|
||||
this.cpu = cpu;
|
||||
return this;
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected Server.State state;
|
||||
protected ResourceUsage cpu;
|
||||
protected ResourceUsage memory;
|
||||
protected ResourceUsage disk;
|
||||
protected ServerUptime uptime;
|
||||
|
||||
/**
|
||||
* @see ServerStatus#getState()
|
||||
*/
|
||||
public T state(Server.State state) {
|
||||
this.state = checkNotNull(state, "state");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder memory(ResourceUsage memory) {
|
||||
this.memory = memory;
|
||||
return this;
|
||||
/**
|
||||
* @see ServerStatus#getCpu()
|
||||
*/
|
||||
public T cpu(ResourceUsage cpu) {
|
||||
this.cpu = checkNotNull(cpu, "cpu");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder disk(ResourceUsage disk) {
|
||||
this.disk = disk;
|
||||
return this;
|
||||
/**
|
||||
* @see ServerStatus#getMemory()
|
||||
*/
|
||||
public T memory(ResourceUsage memory) {
|
||||
this.memory = checkNotNull(memory, "memory");
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder uptime(ServerUptime uptime) {
|
||||
this.uptime = uptime;
|
||||
return this;
|
||||
/**
|
||||
* @see ServerStatus#getDisk()
|
||||
*/
|
||||
public T disk(ResourceUsage disk) {
|
||||
this.disk = checkNotNull(disk, "disk");
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ServerStatus#getUptime()
|
||||
*/
|
||||
public T uptime(ServerUptime uptime) {
|
||||
this.uptime = checkNotNull(uptime, "uptime");
|
||||
return self();
|
||||
}
|
||||
|
||||
public ServerStatus build() {
|
||||
return new ServerStatus(state, cpu, memory, disk, uptime);
|
||||
}
|
||||
|
||||
public Builder fromServerStatus(ServerStatus in) {
|
||||
return state(in.getState()).cpu(in.getCpu()).memory(in.getMemory()).disk(in.getDisk()).uptime(in.getUptime());
|
||||
public T fromServerStatus(ServerStatus in) {
|
||||
return this.state(in.getState()).cpu(in.getCpu()).memory(in.getMemory()).disk(in.getDisk()).uptime(in.getUptime());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,8 +114,12 @@ public class ServerStatus {
|
|||
private final ResourceUsage disk;
|
||||
private final ServerUptime uptime;
|
||||
|
||||
public ServerStatus(Server.State state, ResourceUsage cpu, ResourceUsage memory, ResourceUsage disk, ServerUptime uptime) {
|
||||
this.state = state;
|
||||
@ConstructorProperties({
|
||||
"state", "cpu", "memory", "disk", "uptime"
|
||||
})
|
||||
protected ServerStatus(Server.State state, @Nullable ResourceUsage cpu, @Nullable ResourceUsage memory,
|
||||
@Nullable ResourceUsage disk, @Nullable ServerUptime uptime) {
|
||||
this.state = checkNotNull(state, "state");
|
||||
this.cpu = cpu;
|
||||
this.memory = memory;
|
||||
this.disk = disk;
|
||||
|
@ -91,53 +129,41 @@ public class ServerStatus {
|
|||
/**
|
||||
* @return the state of the server (e.g. "running")
|
||||
*/
|
||||
@Nullable
|
||||
public Server.State getState() {
|
||||
return state;
|
||||
return this.state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return CPU usage information
|
||||
*/
|
||||
@Nullable
|
||||
public ResourceUsage getCpu() {
|
||||
return cpu;
|
||||
return this.cpu;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return details of memory usage and limits
|
||||
*/
|
||||
@Nullable
|
||||
public ResourceUsage getMemory() {
|
||||
return memory;
|
||||
return this.memory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return details of disk usage and limits
|
||||
*/
|
||||
@Nullable
|
||||
public ResourceUsage getDisk() {
|
||||
return disk;
|
||||
return this.disk;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the uptime of the server
|
||||
*/
|
||||
@Nullable
|
||||
public ServerUptime getUptime() {
|
||||
return uptime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof ServerStatus) {
|
||||
final ServerStatus other = (ServerStatus) object;
|
||||
return Objects.equal(state, other.state)
|
||||
&& Objects.equal(cpu, other.cpu)
|
||||
&& Objects.equal(memory, other.memory)
|
||||
&& Objects.equal(disk, other.disk)
|
||||
&& Objects.equal(uptime, other.uptime);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return this.uptime;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -145,10 +171,26 @@ public class ServerStatus {
|
|||
return Objects.hashCode(state, cpu, memory, disk, uptime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ServerStatus that = ServerStatus.class.cast(obj);
|
||||
return Objects.equal(this.state, that.state)
|
||||
&& Objects.equal(this.cpu, that.cpu)
|
||||
&& Objects.equal(this.memory, that.memory)
|
||||
&& Objects.equal(this.disk, that.disk)
|
||||
&& Objects.equal(this.uptime, that.uptime);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("")
|
||||
.add("state", state).add("cpu", cpu).add("memory", memory).add("disk", disk).add("uptime", uptime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[state=%s, cpu=%s, memory=%s, disk=%s, uptime=%s]",
|
||||
state, cpu, memory, disk, uptime);
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
|
@ -18,7 +18,12 @@
|
|||
*/
|
||||
package org.jclouds.glesys.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
|
||||
/**
|
||||
* Represents an 'uptime' duration of server in a Glesys cloud
|
||||
|
@ -27,64 +32,76 @@ import com.google.common.base.Objects;
|
|||
* @see ServerStatus
|
||||
*/
|
||||
public class ServerUptime {
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private long current;
|
||||
private String unit;
|
||||
public Builder<?> toBuilder() {
|
||||
return new ConcreteBuilder().fromServerUptime(this);
|
||||
}
|
||||
|
||||
public Builder current(long current) {
|
||||
public static abstract class Builder<T extends Builder<T>> {
|
||||
protected abstract T self();
|
||||
|
||||
protected long current;
|
||||
protected String unit;
|
||||
|
||||
/**
|
||||
* @see ServerUptime#getCurrent()
|
||||
*/
|
||||
public T current(long current) {
|
||||
this.current = current;
|
||||
return this;
|
||||
return self();
|
||||
}
|
||||
|
||||
public Builder unit(String unit) {
|
||||
this.unit = unit;
|
||||
return this;
|
||||
/**
|
||||
* @see ServerUptime#getUnit()
|
||||
*/
|
||||
public T unit(String unit) {
|
||||
this.unit = checkNotNull(unit, "unit");
|
||||
return self();
|
||||
}
|
||||
|
||||
public ServerUptime build() {
|
||||
return new ServerUptime(current, unit);
|
||||
}
|
||||
|
||||
public Builder fromServerUptime(ServerUptime from) {
|
||||
return current(from.getCurrent()).unit(from.getUnit());
|
||||
public T fromServerUptime(ServerUptime in) {
|
||||
return this.current(in.getCurrent()).unit(in.getUnit());
|
||||
}
|
||||
}
|
||||
|
||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
||||
@Override
|
||||
protected ConcreteBuilder self() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private final long current;
|
||||
private final String unit;
|
||||
|
||||
public ServerUptime(long current, String unit) {
|
||||
@ConstructorProperties({
|
||||
"current", "unit"
|
||||
})
|
||||
protected ServerUptime(long current, String unit) {
|
||||
this.current = current;
|
||||
this.unit = unit;
|
||||
this.unit = checkNotNull(unit, "unit");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the time the server has been up in #unit
|
||||
* @return the time the server has been up in #getUnit()
|
||||
*/
|
||||
public long getCurrent() {
|
||||
return current;
|
||||
return this.current;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the unit used for #time
|
||||
* @return the unit used for #getCurrent()
|
||||
*/
|
||||
public String getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
return object instanceof ServerUptime
|
||||
&& Objects.equal(current, ((ServerUptime) object).getCurrent())
|
||||
&& Objects.equal(unit, ((ServerUptime) object).getUnit());
|
||||
return this.unit;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -92,9 +109,21 @@ public class ServerUptime {
|
|||
return Objects.hashCode(current, unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ServerUptime that = ServerUptime.class.cast(obj);
|
||||
return Objects.equal(this.current, that.current) && Objects.equal(this.unit, that.unit);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return Objects.toStringHelper("").add("current", current).add("unit", unit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[current=%d unit=%s]", current, unit);
|
||||
return string().toString();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue