| 1 | /** |
| 2 | * |
| 3 | * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com> |
| 4 | * |
| 5 | * ==================================================================== |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | * ==================================================================== |
| 18 | */ |
| 19 | package org.jclouds.vcloud.terremark.domain.internal; |
| 20 | |
| 21 | import java.net.URI; |
| 22 | import java.util.Set; |
| 23 | |
| 24 | import org.jclouds.vcloud.domain.ReferenceType; |
| 25 | import org.jclouds.vcloud.domain.network.FenceMode; |
| 26 | import org.jclouds.vcloud.domain.network.firewall.FirewallRule; |
| 27 | import org.jclouds.vcloud.domain.network.internal.VCloudExpressNetworkImpl; |
| 28 | import org.jclouds.vcloud.domain.network.nat.rules.PortForwardingRule; |
| 29 | |
| 30 | /** |
| 31 | * Locations of resources in vCloud |
| 32 | * |
| 33 | * @author Adrian Cole |
| 34 | * |
| 35 | */ |
| 36 | public class TerremarkVCloudExpressNetwork extends VCloudExpressNetworkImpl { |
| 37 | private final ReferenceType networkExtension; |
| 38 | private final ReferenceType ips; |
| 39 | |
| 40 | public TerremarkVCloudExpressNetwork(String name, String type, URI id, String description, Set<String> dnsServers, |
| 41 | String gateway, String netmask, Set<FenceMode> fenceModes, Boolean dhcp, Set<PortForwardingRule> natRules, |
| 42 | Set<FirewallRule> firewallRules, ReferenceType networkExtension, ReferenceType ips) { |
| 43 | super(name, type, id, description, dnsServers, gateway, netmask, fenceModes, dhcp, natRules, firewallRules); |
| 44 | this.networkExtension = networkExtension; |
| 45 | this.ips = ips; |
| 46 | } |
| 47 | |
| 48 | public ReferenceType getNetworkExtension() { |
| 49 | return networkExtension; |
| 50 | } |
| 51 | |
| 52 | public ReferenceType getIps() { |
| 53 | return ips; |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public int hashCode() { |
| 58 | final int prime = 31; |
| 59 | int result = super.hashCode(); |
| 60 | result = prime * result + ((ips == null) ? 0 : ips.hashCode()); |
| 61 | result = prime * result + ((networkExtension == null) ? 0 : networkExtension.hashCode()); |
| 62 | return result; |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public boolean equals(Object obj) { |
| 67 | if (this == obj) |
| 68 | return true; |
| 69 | if (!super.equals(obj)) |
| 70 | return false; |
| 71 | if (getClass() != obj.getClass()) |
| 72 | return false; |
| 73 | TerremarkVCloudExpressNetwork other = (TerremarkVCloudExpressNetwork) obj; |
| 74 | if (ips == null) { |
| 75 | if (other.ips != null) |
| 76 | return false; |
| 77 | } else if (!ips.equals(other.ips)) |
| 78 | return false; |
| 79 | if (networkExtension == null) { |
| 80 | if (other.networkExtension != null) |
| 81 | return false; |
| 82 | } else if (!networkExtension.equals(other.networkExtension)) |
| 83 | return false; |
| 84 | return true; |
| 85 | } |
| 86 | |
| 87 | @Override |
| 88 | public String toString() { |
| 89 | return "[id=" + getHref() + ", name=" + getName() + ", type=" + getType() + ", description=" + description |
| 90 | + ", dhcp=" + dhcp + ", dnsServers=" + dnsServers + ", fenceModes=" + fenceModes + ", firewallRules=" |
| 91 | + firewallRules + ", gateway=" + gateway + ", natRules=" + natRules + ", netmask=" + netmask + ",ips=" |
| 92 | + ips + ", networkExtension=" + networkExtension + "]"; |
| 93 | } |
| 94 | } |