| 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 static com.google.common.base.Preconditions.checkNotNull; |
| 22 | |
| 23 | import java.net.URI; |
| 24 | import java.util.Map; |
| 25 | |
| 26 | import javax.annotation.Nullable; |
| 27 | |
| 28 | import org.jclouds.vcloud.domain.AllocationModel; |
| 29 | import org.jclouds.vcloud.domain.Capacity; |
| 30 | import org.jclouds.vcloud.domain.ReferenceType; |
| 31 | import org.jclouds.vcloud.domain.Task; |
| 32 | import org.jclouds.vcloud.domain.VDCStatus; |
| 33 | import org.jclouds.vcloud.domain.internal.VDCImpl; |
| 34 | import org.jclouds.vcloud.terremark.domain.TerremarkVDC; |
| 35 | |
| 36 | /** |
| 37 | * Locations of resources in Terremark vDC |
| 38 | * |
| 39 | * @author Adrian Cole |
| 40 | * |
| 41 | */ |
| 42 | public class TerremarkVDCImpl extends VDCImpl implements TerremarkVDC { |
| 43 | |
| 44 | private final ReferenceType catalog; |
| 45 | private final ReferenceType publicIps; |
| 46 | private final ReferenceType internetServices; |
| 47 | |
| 48 | /** The serialVersionUID */ |
| 49 | private static final long serialVersionUID = 8464716396538298809L; |
| 50 | |
| 51 | public TerremarkVDCImpl(String name, String type, URI id, VDCStatus status, ReferenceType org, |
| 52 | @Nullable String description, Iterable<Task> tasks, AllocationModel allocationModel, |
| 53 | @Nullable Capacity storageCapacity, @Nullable Capacity cpuCapacity, @Nullable Capacity memoryCapacity, |
| 54 | Map<String, ReferenceType> resourceEntities, Map<String, ReferenceType> availableNetworks, int nicQuota, |
| 55 | int networkQuota, int vmQuota, boolean isEnabled, ReferenceType catalog, ReferenceType publicIps, |
| 56 | ReferenceType internetServices) { |
| 57 | super(name, type, id, status, org, description, tasks, allocationModel, storageCapacity, cpuCapacity, |
| 58 | memoryCapacity, resourceEntities, availableNetworks, nicQuota, networkQuota, vmQuota, isEnabled); |
| 59 | this.catalog = checkNotNull(catalog, "catalog"); |
| 60 | this.publicIps = checkNotNull(publicIps, "publicIps"); |
| 61 | this.internetServices = checkNotNull(internetServices, "internetServices"); |
| 62 | } |
| 63 | |
| 64 | public ReferenceType getCatalog() { |
| 65 | return catalog; |
| 66 | } |
| 67 | |
| 68 | public ReferenceType getPublicIps() { |
| 69 | return publicIps; |
| 70 | } |
| 71 | |
| 72 | public ReferenceType getInternetServices() { |
| 73 | return internetServices; |
| 74 | } |
| 75 | |
| 76 | @Override |
| 77 | public int hashCode() { |
| 78 | final int prime = 31; |
| 79 | int result = super.hashCode(); |
| 80 | result = prime * result + ((catalog == null) ? 0 : catalog.hashCode()); |
| 81 | result = prime * result + ((internetServices == null) ? 0 : internetServices.hashCode()); |
| 82 | result = prime * result + ((publicIps == null) ? 0 : publicIps.hashCode()); |
| 83 | return result; |
| 84 | } |
| 85 | |
| 86 | @Override |
| 87 | public boolean equals(Object obj) { |
| 88 | if (this == obj) |
| 89 | return true; |
| 90 | if (!super.equals(obj)) |
| 91 | return false; |
| 92 | if (getClass() != obj.getClass()) |
| 93 | return false; |
| 94 | TerremarkVDCImpl other = (TerremarkVDCImpl) obj; |
| 95 | if (catalog == null) { |
| 96 | if (other.catalog != null) |
| 97 | return false; |
| 98 | } else if (!catalog.equals(other.catalog)) |
| 99 | return false; |
| 100 | if (internetServices == null) { |
| 101 | if (other.internetServices != null) |
| 102 | return false; |
| 103 | } else if (!internetServices.equals(other.internetServices)) |
| 104 | return false; |
| 105 | if (publicIps == null) { |
| 106 | if (other.publicIps != null) |
| 107 | return false; |
| 108 | } else if (!publicIps.equals(other.publicIps)) |
| 109 | return false; |
| 110 | return true; |
| 111 | } |
| 112 | |
| 113 | } |