vcloud tidies

This commit is contained in:
Adrian Cole 2012-07-12 18:09:14 -07:00
parent d4453b2ac2
commit 397231284d
21 changed files with 329 additions and 515 deletions

View File

@ -92,10 +92,10 @@ import org.jclouds.vcloud.features.VDCAsyncClient;
import org.jclouds.vcloud.features.VDCClient; import org.jclouds.vcloud.features.VDCClient;
import org.jclouds.vcloud.features.VmAsyncClient; import org.jclouds.vcloud.features.VmAsyncClient;
import org.jclouds.vcloud.features.VmClient; import org.jclouds.vcloud.features.VmClient;
import org.jclouds.vcloud.functions.AllCatalogItemsInCatalog; import org.jclouds.vcloud.functions.CatalogItemsInCatalog;
import org.jclouds.vcloud.functions.AllCatalogItemsInOrg; import org.jclouds.vcloud.functions.CatalogItemsInOrg;
import org.jclouds.vcloud.functions.AllCatalogsInOrg; import org.jclouds.vcloud.functions.CatalogsInOrg;
import org.jclouds.vcloud.functions.AllVDCsInOrg; import org.jclouds.vcloud.functions.VDCsInOrg;
import org.jclouds.vcloud.functions.DefaultNetworkNameInTemplate; import org.jclouds.vcloud.functions.DefaultNetworkNameInTemplate;
import org.jclouds.vcloud.functions.OrgsForLocations; import org.jclouds.vcloud.functions.OrgsForLocations;
import org.jclouds.vcloud.functions.OrgsForNames; import org.jclouds.vcloud.functions.OrgsForNames;
@ -179,10 +179,10 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
}).to(new TypeLiteral<FindLocationForResource>() { }).to(new TypeLiteral<FindLocationForResource>() {
}); });
bind(new TypeLiteral<Function<Org, Iterable<Catalog>>>() { bind(new TypeLiteral<Function<Org, Iterable<Catalog>>>() {
}).to(new TypeLiteral<AllCatalogsInOrg>() { }).to(new TypeLiteral<CatalogsInOrg>() {
}); });
bind(new TypeLiteral<Function<Org, Iterable<VDC>>>() { bind(new TypeLiteral<Function<Org, Iterable<VDC>>>() {
}).to(new TypeLiteral<AllVDCsInOrg>() { }).to(new TypeLiteral<VDCsInOrg>() {
}); });
bind(new TypeLiteral<Function<Iterable<String>, Iterable<Org>>>() { bind(new TypeLiteral<Function<Iterable<String>, Iterable<Org>>>() {
}).to(new TypeLiteral<OrgsForNames>() { }).to(new TypeLiteral<OrgsForNames>() {
@ -191,10 +191,10 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
}).to(new TypeLiteral<OrgsForLocations>() { }).to(new TypeLiteral<OrgsForLocations>() {
}); });
bind(new TypeLiteral<Function<Catalog, Iterable<CatalogItem>>>() { bind(new TypeLiteral<Function<Catalog, Iterable<CatalogItem>>>() {
}).to(new TypeLiteral<AllCatalogItemsInCatalog>() { }).to(new TypeLiteral<CatalogItemsInCatalog>() {
}); });
bind(new TypeLiteral<Function<Org, Iterable<CatalogItem>>>() { bind(new TypeLiteral<Function<Org, Iterable<CatalogItem>>>() {
}).to(new TypeLiteral<AllCatalogItemsInOrg>() { }).to(new TypeLiteral<CatalogItemsInOrg>() {
}); });
bindCacheLoaders(); bindCacheLoaders();

View File

@ -18,10 +18,15 @@
*/ */
package org.jclouds.vcloud.domain.internal; package org.jclouds.vcloud.domain.internal;
import static com.google.common.base.Objects.equal;
import java.net.URI; import java.net.URI;
import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.ReferenceType;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
/** /**
* Location of a Rest resource * Location of a Rest resource
* *
@ -60,44 +65,26 @@ public class ReferenceTypeImpl implements ReferenceType {
} }
@Override @Override
public int hashCode() { public boolean equals(Object o) {
final int prime = 31; if (this == o)
int result = 1; return true;
result = prime * result + ((href == null) ? 0 : href.hashCode()); if (o == null || getClass() != o.getClass())
result = prime * result + ((name == null) ? 0 : name.hashCode()); return false;
result = prime * result + ((type == null) ? 0 : type.hashCode()); ReferenceTypeImpl that = ReferenceTypeImpl.class.cast(o);
return result; return equal(this.href, that.href);
} }
@Override @Override
public boolean equals(Object obj) { public int hashCode() {
if (this == obj) return Objects.hashCode(href);
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ReferenceTypeImpl other = (ReferenceTypeImpl) obj;
if (href == null) {
if (other.href != null)
return false;
} else if (!href.equals(other.href))
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (type == null) {
if (other.type != null)
return false;
} else if (!type.equals(other.type))
return false;
return true;
} }
@Override @Override
public String toString() { public String toString() {
return "[href=" + href + ", name=" + name + ", type=" + type + "]"; return string().toString();
}
protected ToStringHelper string() {
return Objects.toStringHelper("").omitNullValues().add("href", href).add("name", name).add("type", type);
} }
} }

View File

@ -89,9 +89,9 @@ public class TaskImpl extends ReferenceTypeImpl implements Task {
@Override @Override
public String toString() { public String toString() {
return Objects.toStringHelper("").add("href", getHref()).add("name", getName()).add("owner", owner).add( return Objects.toStringHelper("").omitNullValues().add("href", getHref()).add("name", getName())
"operation", operation).add("startTime", startTime).add("endTime", endTime) .add("owner", owner).add("operation", operation).add("startTime", startTime).add("endTime", endTime)
.add("expiryTime", expiryTime).add("error", error).toString(); .add("expiryTime", expiryTime).add("error", error).toString();
} }
public Date getExpiryTime() { public Date getExpiryTime() {

View File

@ -18,8 +18,12 @@
*/ */
package org.jclouds.vcloud.domain.network; package org.jclouds.vcloud.domain.network;
import static com.google.common.base.Objects.equal;
import org.jclouds.javax.annotation.Nullable; import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
/** /**
* specifies the properties of the networks DHCP service * specifies the properties of the networks DHCP service
*/ */
@ -80,48 +84,25 @@ public class DhcpService {
} }
@Override @Override
public int hashCode() { public boolean equals(Object o) {
final int prime = 31; if (this == o)
int result = 1; return true;
result = prime * result + ((defaultLeaseTime == null) ? 0 : defaultLeaseTime.hashCode()); if (o == null || getClass() != o.getClass())
result = prime * result + (enabled ? 1231 : 1237); return false;
result = prime * result + ((ipRange == null) ? 0 : ipRange.hashCode()); DhcpService that = DhcpService.class.cast(o);
result = prime * result + ((maxLeaseTime == null) ? 0 : maxLeaseTime.hashCode()); return equal(this.enabled, that.enabled) && equal(this.defaultLeaseTime, that.defaultLeaseTime)
return result; && equal(this.maxLeaseTime, that.maxLeaseTime) && equal(this.ipRange, that.ipRange);
} }
@Override @Override
public boolean equals(Object obj) { public int hashCode() {
if (this == obj) return Objects.hashCode(enabled, defaultLeaseTime, maxLeaseTime, ipRange);
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
DhcpService other = (DhcpService) obj;
if (defaultLeaseTime == null) {
if (other.defaultLeaseTime != null)
return false;
} else if (!defaultLeaseTime.equals(other.defaultLeaseTime))
return false;
if (enabled != other.enabled)
return false;
if (ipRange == null) {
if (other.ipRange != null)
return false;
} else if (!ipRange.equals(other.ipRange))
return false;
if (maxLeaseTime == null) {
if (other.maxLeaseTime != null)
return false;
} else if (!maxLeaseTime.equals(other.maxLeaseTime))
return false;
return true;
} }
@Override @Override
public String toString() { public String toString() {
return "[defaultLeaseTime=" + defaultLeaseTime + ", enabled=" + enabled + ", ipRange=" + ipRange return Objects.toStringHelper("").omitNullValues().add("enabled", enabled)
+ ", maxLeaseTime=" + maxLeaseTime + "]"; .add("defaultLeaseTime", defaultLeaseTime).add("maxLeaseTime", maxLeaseTime).add("ipRange", ipRange)
.toString();
} }
} }

View File

@ -18,8 +18,12 @@
*/ */
package org.jclouds.vcloud.domain.network; package org.jclouds.vcloud.domain.network;
import static com.google.common.base.Objects.equal;
import org.jclouds.javax.annotation.Nullable; import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
/** /**
* The Features element defines the DHCP and firewall features of a network. * The Features element defines the DHCP and firewall features of a network.
*/ */
@ -69,46 +73,25 @@ public class Features {
} }
@Override @Override
public int hashCode() { public boolean equals(Object o) {
final int prime = 31; if (this == o)
int result = 1; return true;
result = prime * result + ((dhcpService == null) ? 0 : dhcpService.hashCode()); if (o == null || getClass() != o.getClass())
result = prime * result + ((firewallService == null) ? 0 : firewallService.hashCode()); return false;
result = prime * result + ((natService == null) ? 0 : natService.hashCode()); Features that = Features.class.cast(o);
return result; return equal(this.dhcpService, that.dhcpService) && equal(this.firewallService, that.firewallService)
&& equal(this.natService, that.natService);
} }
@Override @Override
public boolean equals(Object obj) { public int hashCode() {
if (this == obj) return Objects.hashCode(dhcpService, firewallService, natService);
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Features other = (Features) obj;
if (dhcpService == null) {
if (other.dhcpService != null)
return false;
} else if (!dhcpService.equals(other.dhcpService))
return false;
if (firewallService == null) {
if (other.firewallService != null)
return false;
} else if (!firewallService.equals(other.firewallService))
return false;
if (natService == null) {
if (other.natService != null)
return false;
} else if (!natService.equals(other.natService))
return false;
return true;
} }
@Override @Override
public String toString() { public String toString() {
return "[dhcpService=" + dhcpService + ", firewallService=" + firewallService + ", natService=" + natService return Objects.toStringHelper("").omitNullValues().add("dhcpService", dhcpService)
+ "]"; .add("firewallService", firewallService).add("natService", natService).toString();
} }
} }

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.vcloud.domain.network; package org.jclouds.vcloud.domain.network;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.List; import java.util.List;
@ -25,6 +26,8 @@ import java.util.List;
import org.jclouds.javax.annotation.Nullable; import org.jclouds.javax.annotation.Nullable;
import org.jclouds.vcloud.domain.network.firewall.FirewallRule; import org.jclouds.vcloud.domain.network.firewall.FirewallRule;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@ -61,36 +64,25 @@ public class FirewallService {
} }
@Override @Override
public int hashCode() { public boolean equals(Object o) {
final int prime = 31; if (this == o)
int result = 1; return true;
result = prime * result + (enabled ? 1231 : 1237); if (o == null || getClass() != o.getClass())
result = prime * result + ((firewallRules == null) ? 0 : firewallRules.hashCode()); return false;
return result; FirewallService that = FirewallService.class.cast(o);
return equal(this.enabled, that.enabled) && equal(this.firewallRules, that.firewallRules);
} }
@Override @Override
public boolean equals(Object obj) { public int hashCode() {
if (this == obj) return Objects.hashCode(enabled, firewallRules);
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
FirewallService other = (FirewallService) obj;
if (enabled != other.enabled)
return false;
if (firewallRules == null) {
if (other.firewallRules != null)
return false;
} else if (!firewallRules.equals(other.firewallRules))
return false;
return true;
} }
@Override @Override
public String toString() { public String toString() {
return "[enabled=" + enabled + ", firewallRules=" + firewallRules + "]"; ToStringHelper helper = Objects.toStringHelper("").omitNullValues().add("enabled", enabled);
if (firewallRules.size() > 0)
helper.add("firewallRules", firewallRules);
return helper.toString();
} }
} }

View File

@ -18,8 +18,11 @@
*/ */
package org.jclouds.vcloud.domain.network; package org.jclouds.vcloud.domain.network;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Objects;
/** /**
* The IpRange element defines a range of IP addresses available on a network. * The IpRange element defines a range of IP addresses available on a network.
* *
@ -52,38 +55,24 @@ public class IpRange {
} }
@Override @Override
public int hashCode() { public boolean equals(Object o) {
final int prime = 31; if (this == o)
int result = 1; return true;
result = prime * result + ((endAddress == null) ? 0 : endAddress.hashCode()); if (o == null || getClass() != o.getClass())
result = prime * result + ((startAddress == null) ? 0 : startAddress.hashCode()); return false;
return result; IpRange that = IpRange.class.cast(o);
return equal(this.startAddress, that.startAddress) && equal(this.endAddress, that.endAddress);
} }
@Override @Override
public boolean equals(Object obj) { public int hashCode() {
if (this == obj) return Objects.hashCode(startAddress, endAddress);
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
IpRange other = (IpRange) obj;
if (endAddress == null) {
if (other.endAddress != null)
return false;
} else if (!endAddress.equals(other.endAddress))
return false;
if (startAddress == null) {
if (other.startAddress != null)
return false;
} else if (!startAddress.equals(other.startAddress))
return false;
return true;
} }
@Override @Override
public String toString() { public String toString() {
return "[startAddress=" + startAddress + ", endAddress=" + endAddress + "]"; return Objects.toStringHelper("").omitNullValues().add("startAddress", startAddress)
.add("endAddress", endAddress).toString();
} }
} }

View File

@ -18,12 +18,15 @@
*/ */
package org.jclouds.vcloud.domain.network; package org.jclouds.vcloud.domain.network;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Set; import java.util.Set;
import org.jclouds.javax.annotation.Nullable; import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -138,73 +141,30 @@ public class IpScope {
} }
@Override @Override
public int hashCode() { public boolean equals(Object o) {
final int prime = 31; if (this == o)
int result = 1; return true;
result = prime * result + ((allocatedIpAddresses == null) ? 0 : allocatedIpAddresses.hashCode()); if (o == null || getClass() != o.getClass())
result = prime * result + ((dns1 == null) ? 0 : dns1.hashCode()); return false;
result = prime * result + ((dns2 == null) ? 0 : dns2.hashCode()); IpScope that = IpScope.class.cast(o);
result = prime * result + ((dnsSuffix == null) ? 0 : dnsSuffix.hashCode()); return equal(this.inherited, that.inherited) && equal(this.gateway, that.gateway)
result = prime * result + ((gateway == null) ? 0 : gateway.hashCode()); && equal(this.netmask, that.netmask) && equal(this.dns1, that.dns1) && equal(this.dns2, that.dns2)
result = prime * result + (inherited ? 1231 : 1237); && equal(this.dnsSuffix, that.dnsSuffix) && equal(this.ipRanges, ipRanges) && equal(this.allocatedIpAddresses, allocatedIpAddresses);
result = prime * result + ((ipRanges == null) ? 0 : ipRanges.hashCode());
result = prime * result + ((netmask == null) ? 0 : netmask.hashCode());
return result;
} }
@Override @Override
public boolean equals(Object obj) { public int hashCode() {
if (this == obj) return Objects.hashCode(inherited, gateway, netmask, dns1, dns2, dnsSuffix, ipRanges, allocatedIpAddresses);
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
IpScope other = (IpScope) obj;
if (allocatedIpAddresses == null) {
if (other.allocatedIpAddresses != null)
return false;
} else if (!allocatedIpAddresses.equals(other.allocatedIpAddresses))
return false;
if (dns1 == null) {
if (other.dns1 != null)
return false;
} else if (!dns1.equals(other.dns1))
return false;
if (dns2 == null) {
if (other.dns2 != null)
return false;
} else if (!dns2.equals(other.dns2))
return false;
if (dnsSuffix == null) {
if (other.dnsSuffix != null)
return false;
} else if (!dnsSuffix.equals(other.dnsSuffix))
return false;
if (gateway == null) {
if (other.gateway != null)
return false;
} else if (!gateway.equals(other.gateway))
return false;
if (inherited != other.inherited)
return false;
if (ipRanges == null) {
if (other.ipRanges != null)
return false;
} else if (!ipRanges.equals(other.ipRanges))
return false;
if (netmask == null) {
if (other.netmask != null)
return false;
} else if (!netmask.equals(other.netmask))
return false;
return true;
} }
@Override @Override
public String toString() { public String toString() {
return "[allocatedIpAddresses=" + allocatedIpAddresses + ", dns1=" + dns1 + ", dns2=" + dns2 + ", dnsSuffix=" ToStringHelper helper = Objects.toStringHelper("").omitNullValues().add("inherited", inherited).add("gateway", gateway)
+ dnsSuffix + ", gateway=" + gateway + ", inherited=" + inherited + ", ipRanges=" + ipRanges .add("netmask", netmask).add("dns1", dns1).add("dns2", dns2).add("dnsSuffix", dnsSuffix);
+ ", netmask=" + netmask + "]"; if (ipRanges.size() >0)
helper.add("ipRanges", ipRanges);
if (allocatedIpAddresses.size() >0)
helper.add("allocatedIpAddresses", allocatedIpAddresses);
return helper.toString();
} }
} }

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.vcloud.domain.network; package org.jclouds.vcloud.domain.network;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.List; import java.util.List;
@ -27,6 +28,8 @@ import org.jclouds.vcloud.domain.network.nat.NatPolicy;
import org.jclouds.vcloud.domain.network.nat.NatRule; import org.jclouds.vcloud.domain.network.nat.NatRule;
import org.jclouds.vcloud.domain.network.nat.NatType; import org.jclouds.vcloud.domain.network.nat.NatType;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@ -88,48 +91,27 @@ public class NatService {
} }
@Override @Override
public int hashCode() { public boolean equals(Object o) {
final int prime = 31; if (this == o)
int result = 1; return true;
result = prime * result + (enabled ? 1231 : 1237); if (o == null || getClass() != o.getClass())
result = prime * result + ((natRules == null) ? 0 : natRules.hashCode()); return false;
result = prime * result + ((policy == null) ? 0 : policy.hashCode()); NatService that = NatService.class.cast(o);
result = prime * result + ((type == null) ? 0 : type.hashCode()); return equal(this.enabled, that.enabled) && equal(this.type, that.type)
return result; && equal(this.policy, that.policy) && equal(this.natRules, that.natRules);
} }
@Override @Override
public boolean equals(Object obj) { public int hashCode() {
if (this == obj) return Objects.hashCode(enabled, type, policy, natRules);
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
NatService other = (NatService) obj;
if (enabled != other.enabled)
return false;
if (natRules == null) {
if (other.natRules != null)
return false;
} else if (!natRules.equals(other.natRules))
return false;
if (policy == null) {
if (other.policy != null)
return false;
} else if (!policy.equals(other.policy))
return false;
if (type == null) {
if (other.type != null)
return false;
} else if (!type.equals(other.type))
return false;
return true;
} }
@Override @Override
public String toString() { public String toString() {
return "[enabled=" + enabled + ", natRules=" + natRules + ", policy=" + policy + ", type=" + type + "]"; ToStringHelper helper = Objects.toStringHelper("").omitNullValues().add("enabled", enabled)
.add("type", type).add("policy", policy);
if (natRules.size() >0)
helper.add("natRules", natRules);
return helper.toString();
} }
} }

View File

@ -24,7 +24,7 @@ import java.util.Set;
import org.jclouds.javax.annotation.Nullable; import org.jclouds.javax.annotation.Nullable;
import org.jclouds.vcloud.domain.ReferenceType; import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.internal.VDCImpl; import org.jclouds.vcloud.domain.network.internal.OrgNetworkImpl;
import com.google.inject.ImplementedBy; import com.google.inject.ImplementedBy;
@ -34,7 +34,7 @@ import com.google.inject.ImplementedBy;
* @author Adrian Cole * @author Adrian Cole
*/ */
@org.jclouds.vcloud.endpoints.Network @org.jclouds.vcloud.endpoints.Network
@ImplementedBy(VDCImpl.class) @ImplementedBy(OrgNetworkImpl.class)
public interface OrgNetwork extends ReferenceType { public interface OrgNetwork extends ReferenceType {
/** /**
* The org this network belongs to. * The org this network belongs to.

View File

@ -18,6 +18,10 @@
*/ */
package org.jclouds.vcloud.domain.network.firewall; package org.jclouds.vcloud.domain.network.firewall;
import static com.google.common.base.Objects.equal;
import com.google.common.base.Objects;
/** /**
* The Protocols element specifies the protocols to which firewall rules apply. * The Protocols element specifies the protocols to which firewall rules apply.
* *
@ -49,33 +53,23 @@ public class FirewallProtocols {
} }
@Override @Override
public int hashCode() { public boolean equals(Object o) {
final int prime = 31; if (this == o)
int result = 1; return true;
result = prime * result + (tcp ? 1231 : 1237); if (o == null || getClass() != o.getClass())
result = prime * result + (udp ? 1231 : 1237); return false;
return result; FirewallProtocols that = FirewallProtocols.class.cast(o);
return equal(this.tcp, that.tcp) && equal(this.udp, that.udp);
} }
@Override @Override
public boolean equals(Object obj) { public int hashCode() {
if (this == obj) return Objects.hashCode(tcp, udp);
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
FirewallProtocols other = (FirewallProtocols) obj;
if (tcp != other.tcp)
return false;
if (udp != other.udp)
return false;
return true;
} }
@Override @Override
public String toString() { public String toString() {
return "Protocols [tcp=" + tcp + ", udp=" + udp + "]"; return Objects.toStringHelper("").omitNullValues().add("tcp", tcp).add("udp", udp).toString();
} }
} }

View File

@ -18,10 +18,13 @@
*/ */
package org.jclouds.vcloud.domain.network.firewall; package org.jclouds.vcloud.domain.network.firewall;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.javax.annotation.Nullable; import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
/** /**
* The FirewallRule element defines a single firewall rule. * The FirewallRule element defines a single firewall rule.
* *
@ -98,58 +101,27 @@ public class FirewallRule {
} }
@Override @Override
public int hashCode() { public boolean equals(Object o) {
final int prime = 31; if (this == o)
int result = 1; return true;
result = prime * result + ((description == null) ? 0 : description.hashCode()); if (o == null || getClass() != o.getClass())
result = prime * result + ((destinationIp == null) ? 0 : destinationIp.hashCode()); return false;
result = prime * result + (enabled ? 1231 : 1237); FirewallRule that = FirewallRule.class.cast(o);
result = prime * result + ((policy == null) ? 0 : policy.hashCode()); return equal(this.enabled, that.enabled) && equal(this.description, that.description)
result = prime * result + port; && equal(this.policy, that.policy) && equal(this.protocols, that.protocols) && equal(this.port, that.port)
result = prime * result + ((protocols == null) ? 0 : protocols.hashCode()); && equal(this.destinationIp, that.destinationIp);
return result;
} }
@Override @Override
public boolean equals(Object obj) { public int hashCode() {
if (this == obj) return Objects.hashCode(enabled, description, policy, protocols, port, destinationIp);
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
FirewallRule other = (FirewallRule) obj;
if (description == null) {
if (other.description != null)
return false;
} else if (!description.equals(other.description))
return false;
if (destinationIp == null) {
if (other.destinationIp != null)
return false;
} else if (!destinationIp.equals(other.destinationIp))
return false;
if (enabled != other.enabled)
return false;
if (policy == null) {
if (other.policy != null)
return false;
} else if (!policy.equals(other.policy))
return false;
if (port != other.port)
return false;
if (protocols == null) {
if (other.protocols != null)
return false;
} else if (!protocols.equals(other.protocols))
return false;
return true;
} }
@Override @Override
public String toString() { public String toString() {
return "[description=" + description + ", destinationIp=" + destinationIp + ", enabled=" + enabled + ", policy=" return Objects.toStringHelper("").omitNullValues().add("enabled", enabled).add("description", description)
+ policy + ", port=" + port + ", protocols=" + protocols + "]"; .add("policy", policy).add("protocols", protocols).add("port", port).add("destinationIp", destinationIp)
.toString();
} }
} }

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.vcloud.domain.network.internal; package org.jclouds.vcloud.domain.network.internal;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI; import java.net.URI;
@ -33,6 +34,8 @@ import org.jclouds.vcloud.domain.network.FenceMode;
import org.jclouds.vcloud.domain.network.IpScope; import org.jclouds.vcloud.domain.network.IpScope;
import org.jclouds.vcloud.domain.network.OrgNetwork; import org.jclouds.vcloud.domain.network.OrgNetwork;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
@ -116,52 +119,25 @@ public class OrgNetworkImpl extends ReferenceTypeImpl implements OrgNetwork {
} }
@Override @Override
public int hashCode() { public boolean equals(Object o) {
final int prime = 31; if (this == o)
int result = 1; return true;
result = prime * result + ((features == null) ? 0 : features.hashCode()); if (o == null || getClass() != o.getClass())
result = prime * result + ((fenceMode == null) ? 0 : fenceMode.hashCode()); return false;
result = prime * result + ((ipScope == null) ? 0 : ipScope.hashCode()); ConfigurationImpl that = ConfigurationImpl.class.cast(o);
result = prime * result + ((parentNetwork == null) ? 0 : parentNetwork.hashCode()); return equal(this.ipScope, that.ipScope) && equal(this.parentNetwork, that.parentNetwork)
return result; && equal(this.fenceMode, that.fenceMode) && equal(this.features, that.features);
} }
@Override @Override
public boolean equals(Object obj) { public int hashCode() {
if (this == obj) return Objects.hashCode(ipScope, parentNetwork, fenceMode, features);
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ConfigurationImpl other = (ConfigurationImpl) obj;
if (features == null) {
if (other.features != null)
return false;
} else if (!features.equals(other.features))
return false;
if (fenceMode == null) {
if (other.fenceMode != null)
return false;
} else if (!fenceMode.equals(other.fenceMode))
return false;
if (ipScope == null) {
if (other.ipScope != null)
return false;
} else if (!ipScope.equals(other.ipScope))
return false;
if (parentNetwork == null) {
if (other.parentNetwork != null)
return false;
} else if (!parentNetwork.equals(other.parentNetwork))
return false;
return true;
} }
@Override @Override
public String toString() { public String toString() {
return "[features=" + features + ", fenceMode=" + fenceMode + ", ipScope=" + ipScope + ", parentNetwork=" return Objects.toStringHelper("").omitNullValues().add("ipScope", ipScope).add("parentNetwork", parentNetwork)
+ parentNetwork + "]"; .add("fenceMode", fenceMode).add("features", features).toString();
} }
} }
@ -215,65 +191,14 @@ public class OrgNetworkImpl extends ReferenceTypeImpl implements OrgNetwork {
} }
@Override @Override
public int hashCode() { public ToStringHelper string() {
final int prime = 31; ToStringHelper helper = super.string().add("org", org).add("description", description)
int result = super.hashCode(); .add("configuration", configuration).add("networkPool", networkPool);
result = prime * result + ((allowedExternalIpAddresses == null) ? 0 : allowedExternalIpAddresses.hashCode()); if (allowedExternalIpAddresses.size() > 0)
result = prime * result + ((configuration == null) ? 0 : configuration.hashCode()); helper.add("allowedExternalIpAddresses", allowedExternalIpAddresses);
result = prime * result + ((description == null) ? 0 : description.hashCode()); if (tasks.size() > 0)
result = prime * result + ((networkPool == null) ? 0 : networkPool.hashCode()); helper.add("tasks", tasks);
result = prime * result + ((org == null) ? 0 : org.hashCode()); return helper;
result = prime * result + ((tasks == null) ? 0 : tasks.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
OrgNetworkImpl other = (OrgNetworkImpl) obj;
if (allowedExternalIpAddresses == null) {
if (other.allowedExternalIpAddresses != null)
return false;
} else if (!allowedExternalIpAddresses.equals(other.allowedExternalIpAddresses))
return false;
if (configuration == null) {
if (other.configuration != null)
return false;
} else if (!configuration.equals(other.configuration))
return false;
if (description == null) {
if (other.description != null)
return false;
} else if (!description.equals(other.description))
return false;
if (networkPool == null) {
if (other.networkPool != null)
return false;
} else if (!networkPool.equals(other.networkPool))
return false;
if (org == null) {
if (other.org != null)
return false;
} else if (!org.equals(other.org))
return false;
if (tasks == null) {
if (other.tasks != null)
return false;
} else if (!tasks.equals(other.tasks))
return false;
return true;
}
@Override
public String toString() {
return "[allowedExternalIpAddresses=" + allowedExternalIpAddresses + ", configuration=" + configuration
+ ", description=" + description + ", networkPool=" + networkPool + ", org=" + org + ", tasks=" + tasks
+ "]";
} }
} }

View File

@ -18,11 +18,14 @@
*/ */
package org.jclouds.vcloud.domain.network.nat.rules; package org.jclouds.vcloud.domain.network.nat.rules;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.javax.annotation.Nullable; import org.jclouds.javax.annotation.Nullable;
import org.jclouds.vcloud.domain.network.nat.NatRule; import org.jclouds.vcloud.domain.network.nat.NatRule;
import com.google.common.base.Objects;
/** /**
* The OneToOneVmRule element describes a NAT rule that specifies network address translation * The OneToOneVmRule element describes a NAT rule that specifies network address translation
* details for a single virtual machine. The external IP address can be specified manually or * details for a single virtual machine. The external IP address can be specified manually or
@ -48,6 +51,28 @@ public class OneToOneVmRule implements NatRule {
this.vmNicId = vmNicId; this.vmNicId = vmNicId;
} }
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
OneToOneVmRule that = OneToOneVmRule.class.cast(o);
return equal(this.mappingMode, that.mappingMode) && equal(this.externalIP, that.externalIP)
&& equal(this.vAppScopedVmId, that.vAppScopedVmId) && equal(this.vmNicId, that.vmNicId);
}
@Override
public int hashCode() {
return Objects.hashCode(mappingMode, externalIP, vAppScopedVmId, vmNicId);
}
@Override
public String toString() {
return Objects.toStringHelper("").omitNullValues().add("mappingMode", mappingMode).add("externalIP", externalIP)
.add("vAppScopedVmId", vAppScopedVmId).add("vmNicId", vmNicId).toString();
}
/** /**
* @return how IP address mapping is implemented by the NAT service * @return how IP address mapping is implemented by the NAT service
* @since vcloud 0.9 * @since vcloud 0.9

View File

@ -18,11 +18,14 @@
*/ */
package org.jclouds.vcloud.domain.network.nat.rules; package org.jclouds.vcloud.domain.network.nat.rules;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.vcloud.domain.network.nat.NatProtocol; import org.jclouds.vcloud.domain.network.nat.NatProtocol;
import org.jclouds.vcloud.domain.network.nat.NatRule; import org.jclouds.vcloud.domain.network.nat.NatRule;
import com.google.common.base.Objects;
/** /**
* The PortForwardingRule element describes a NAT rule that maps an IP address and port in an * The PortForwardingRule element describes a NAT rule that maps an IP address and port in an
* organization network to an external IP address and port. * organization network to an external IP address and port.
@ -44,7 +47,6 @@ public class PortForwardingRule implements NatRule {
this.internalIP = checkNotNull(internalIP, "internalIP"); this.internalIP = checkNotNull(internalIP, "internalIP");
this.internalPort = internalPort; this.internalPort = internalPort;
this.protocol = checkNotNull(protocol, "protocol"); this.protocol = checkNotNull(protocol, "protocol");
} }
/** /**
@ -85,52 +87,27 @@ public class PortForwardingRule implements NatRule {
} }
@Override @Override
public int hashCode() { public boolean equals(Object o) {
final int prime = 31; if (this == o)
int result = 1; return true;
result = prime * result + ((externalIP == null) ? 0 : externalIP.hashCode()); if (o == null || getClass() != o.getClass())
result = prime * result + externalPort; return false;
result = prime * result + ((internalIP == null) ? 0 : internalIP.hashCode()); PortForwardingRule that = PortForwardingRule.class.cast(o);
result = prime * result + internalPort; return equal(this.externalIP, that.externalIP) && equal(this.externalPort, that.externalPort)
result = prime * result + ((protocol == null) ? 0 : protocol.hashCode()); && equal(this.internalIP, that.internalIP) && equal(this.internalPort, that.internalPort)
return result; && equal(this.protocol, that.protocol);
} }
@Override @Override
public boolean equals(Object obj) { public int hashCode() {
if (this == obj) return Objects.hashCode(externalIP, externalPort, internalIP, internalPort, protocol);
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
PortForwardingRule other = (PortForwardingRule) obj;
if (externalIP == null) {
if (other.externalIP != null)
return false;
} else if (!externalIP.equals(other.externalIP))
return false;
if (externalPort != other.externalPort)
return false;
if (internalIP == null) {
if (other.internalIP != null)
return false;
} else if (!internalIP.equals(other.internalIP))
return false;
if (internalPort != other.internalPort)
return false;
if (protocol == null) {
if (other.protocol != null)
return false;
} else if (!protocol.equals(other.protocol))
return false;
return true;
} }
@Override @Override
public String toString() { public String toString() {
return "[externalIP=" + externalIP + ", externalPort=" + externalPort + ", internalIP=" + internalIP return Objects.toStringHelper("").omitNullValues().add("externalIP", externalIP)
+ ", internalPort=" + internalPort + ", protocol=" + protocol + "]"; .add("externalPort", externalPort).add("internalIP", internalIP).add("internalPort", internalPort)
.add("protocol", protocol).toString();
} }
} }

View File

@ -18,12 +18,15 @@
*/ */
package org.jclouds.vcloud.domain.network.nat.rules; package org.jclouds.vcloud.domain.network.nat.rules;
import static com.google.common.base.Objects.equal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import org.jclouds.javax.annotation.Nullable; import org.jclouds.javax.annotation.Nullable;
import org.jclouds.vcloud.domain.network.nat.NatProtocol; import org.jclouds.vcloud.domain.network.nat.NatProtocol;
import org.jclouds.vcloud.domain.network.nat.NatRule; import org.jclouds.vcloud.domain.network.nat.NatRule;
import com.google.common.base.Objects;
/** /**
* The VmRule element describes a NAT rule that maps an IP address and port in a vApp network to an * The VmRule element describes a NAT rule that maps an IP address and port in a vApp network to an
* external IP address and port. The external IP address, external port, and internal port are * external IP address and port. The external IP address, external port, and internal port are
@ -54,7 +57,7 @@ public class VmRule implements NatRule {
} }
/** /**
* IP address to which this NAT rule maps the IP address specified in the InternalIp element. * IP address to which this NAT rule maps the IP address specified in the vAppScopedLocalId element.
*/ */
@Nullable @Nullable
public String getExternalIP() { public String getExternalIP() {
@ -101,55 +104,27 @@ public class VmRule implements NatRule {
} }
@Override @Override
public int hashCode() { public boolean equals(Object o) {
final int prime = 31; if (this == o)
int result = 1; return true;
result = prime * result + ((externalIP == null) ? 0 : externalIP.hashCode()); if (o == null || getClass() != o.getClass())
result = prime * result + externalPort; return false;
result = prime * result + internalPort; VmRule that = VmRule.class.cast(o);
result = prime * result + ((protocol == null) ? 0 : protocol.hashCode()); return equal(this.externalIP, that.externalIP) && equal(this.externalPort, that.externalPort)
result = prime * result + ((vAppScopedLocalId == null) ? 0 : vAppScopedLocalId.hashCode()); && equal(this.vAppScopedLocalId, that.vAppScopedLocalId) && equal(this.vmNicId, that.vmNicId)
result = prime * result + vmNicId; && equal(this.internalPort, that.internalPort) && equal(this.protocol, that.protocol);
return result;
} }
@Override @Override
public boolean equals(Object obj) { public int hashCode() {
if (this == obj) return Objects.hashCode(externalIP, externalPort, vAppScopedLocalId, vmNicId, internalPort, protocol);
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
VmRule other = (VmRule) obj;
if (externalIP == null) {
if (other.externalIP != null)
return false;
} else if (!externalIP.equals(other.externalIP))
return false;
if (externalPort != other.externalPort)
return false;
if (internalPort != other.internalPort)
return false;
if (protocol == null) {
if (other.protocol != null)
return false;
} else if (!protocol.equals(other.protocol))
return false;
if (vAppScopedLocalId == null) {
if (other.vAppScopedLocalId != null)
return false;
} else if (!vAppScopedLocalId.equals(other.vAppScopedLocalId))
return false;
if (vmNicId != other.vmNicId)
return false;
return true;
} }
@Override @Override
public String toString() { public String toString() {
return "[externalIP=" + externalIP + ", externalPort=" + externalPort + ", internalPort=" + internalPort return Objects.toStringHelper("").omitNullValues().add("externalIP", externalIP)
+ ", protocol=" + protocol + ", vAppScopedLocalId=" + vAppScopedLocalId + ", vmNicId=" + vmNicId + "]"; .add("externalPort", externalPort).add("vAppScopedLocalId", vAppScopedLocalId).add("vmNicId", vmNicId)
.add("internalPort", internalPort).add("protocol", protocol).toString();
} }
} }

View File

@ -45,7 +45,7 @@ import com.google.common.base.Predicate;
* @author Adrian Cole * @author Adrian Cole
*/ */
@Singleton @Singleton
public class AllCatalogItemsInCatalog implements Function<Catalog, Iterable<CatalogItem>> { public class CatalogItemsInCatalog implements Function<Catalog, Iterable<CatalogItem>> {
@Resource @Resource
public Logger logger = Logger.NULL; public Logger logger = Logger.NULL;
@ -53,7 +53,7 @@ public class AllCatalogItemsInCatalog implements Function<Catalog, Iterable<Cata
private final ExecutorService executor; private final ExecutorService executor;
@Inject @Inject
AllCatalogItemsInCatalog(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) { CatalogItemsInCatalog(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.aclient = aclient; this.aclient = aclient;
this.executor = executor; this.executor = executor;
} }

View File

@ -32,14 +32,14 @@ import com.google.common.collect.Iterables;
* @author Adrian Cole * @author Adrian Cole
*/ */
@Singleton @Singleton
public class AllCatalogItemsInOrg implements Function<Org, Iterable<CatalogItem>> { public class CatalogItemsInOrg implements Function<Org, Iterable<CatalogItem>> {
private final Function<Org, Iterable<Catalog>> allCatalogsInOrg; private final Function<Org, Iterable<Catalog>> allCatalogsInOrg;
private final Function<Catalog, Iterable<CatalogItem>> allCatalogItemsInCatalog; private final Function<Catalog, Iterable<CatalogItem>> allCatalogItemsInCatalog;
@Inject @Inject
AllCatalogItemsInOrg(Function<Org, Iterable<Catalog>> allCatalogsInOrg, CatalogItemsInOrg(Function<Org, Iterable<Catalog>> allCatalogsInOrg,
Function<Catalog, Iterable<CatalogItem>> allCatalogItemsInCatalog) { Function<Catalog, Iterable<CatalogItem>> allCatalogItemsInCatalog) {
this.allCatalogsInOrg = allCatalogsInOrg; this.allCatalogsInOrg = allCatalogsInOrg;
this.allCatalogItemsInCatalog = allCatalogItemsInCatalog; this.allCatalogItemsInCatalog = allCatalogItemsInCatalog;

View File

@ -42,7 +42,7 @@ import com.google.common.base.Function;
* @author Adrian Cole * @author Adrian Cole
*/ */
@Singleton @Singleton
public class AllCatalogsInOrg implements Function<Org, Iterable<Catalog>> { public class CatalogsInOrg implements Function<Org, Iterable<Catalog>> {
@Resource @Resource
public Logger logger = Logger.NULL; public Logger logger = Logger.NULL;
@ -50,7 +50,7 @@ public class AllCatalogsInOrg implements Function<Org, Iterable<Catalog>> {
private final ExecutorService executor; private final ExecutorService executor;
@Inject @Inject
AllCatalogsInOrg(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) { CatalogsInOrg(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.aclient = aclient; this.aclient = aclient;
this.executor = executor; this.executor = executor;
} }

View File

@ -0,0 +1,72 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.functions;
import static org.jclouds.concurrent.FutureIterables.transformParallel;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import javax.annotation.Resource;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.Constants;
import org.jclouds.logging.Logger;
import org.jclouds.util.Iterables2;
import org.jclouds.vcloud.VCloudAsyncClient;
import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.network.OrgNetwork;
import com.google.common.base.Function;
/**
* @author Adrian Cole
*/
@Singleton
public class NetworksInOrg implements Function<Org, Iterable<OrgNetwork>> {
@Resource
public Logger logger = Logger.NULL;
private final VCloudAsyncClient aclient;
private final ExecutorService executor;
@Inject
NetworksInOrg(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.aclient = aclient;
this.executor = executor;
}
@Override
public Iterable<OrgNetwork> apply(final Org org) {
Iterable<OrgNetwork> networkItems = transformParallel(org.getNetworks().values(),
new Function<ReferenceType, Future<? extends OrgNetwork>>() {
@Override
public Future<? extends OrgNetwork> apply(ReferenceType from) {
return aclient.getNetworkClient().getNetwork(from.getHref());
}
}, executor, null, logger, "OrgNetworks in org " + org.getName());
return Iterables2.concreteCopy(networkItems);
}
}

View File

@ -42,7 +42,7 @@ import com.google.common.base.Function;
* @author Adrian Cole * @author Adrian Cole
*/ */
@Singleton @Singleton
public class AllVDCsInOrg implements Function<Org, Iterable<VDC>> { public class VDCsInOrg implements Function<Org, Iterable<VDC>> {
@Resource @Resource
public Logger logger = Logger.NULL; public Logger logger = Logger.NULL;
@ -50,7 +50,7 @@ public class AllVDCsInOrg implements Function<Org, Iterable<VDC>> {
private final ExecutorService executor; private final ExecutorService executor;
@Inject @Inject
AllVDCsInOrg(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) { VDCsInOrg(VCloudAsyncClient aclient, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
this.aclient = aclient; this.aclient = aclient;
this.executor = executor; this.executor = executor;
} }