| 1 | /** |
| 2 | * Licensed to jclouds, Inc. (jclouds) under one or more |
| 3 | * contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. jclouds licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. 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, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.jclouds.trmk.vcloud_0_8.domain.internal; |
| 20 | |
| 21 | import java.net.URI; |
| 22 | import java.util.Map; |
| 23 | |
| 24 | import com.google.common.collect.ImmutableMap; |
| 25 | import org.jclouds.javax.annotation.Nullable; |
| 26 | import org.jclouds.trmk.vcloud_0_8.domain.Org; |
| 27 | import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType; |
| 28 | |
| 29 | import static com.google.common.base.Preconditions.checkNotNull; |
| 30 | |
| 31 | /** |
| 32 | * Locations of resources in vCloud |
| 33 | * |
| 34 | * @author Adrian Cole |
| 35 | * |
| 36 | */ |
| 37 | public class OrgImpl extends ReferenceTypeImpl implements Org { |
| 38 | @Nullable |
| 39 | private final String description; |
| 40 | private final Map<String, ReferenceType> catalogs; |
| 41 | private final Map<String, ReferenceType> vdcs; |
| 42 | private final ReferenceType keys; |
| 43 | private final ImmutableMap<String, ReferenceType> tasksLists; |
| 44 | |
| 45 | public OrgImpl(String name, String type, URI id, String description, Map<String, ReferenceType> catalogs, |
| 46 | Map<String, ReferenceType> vdcs, Map<String, ReferenceType> tasksLists, ReferenceType keys) { |
| 47 | super(name, type, id); |
| 48 | this.description = description; |
| 49 | this.catalogs = ImmutableMap.copyOf(checkNotNull(catalogs, "catalogs")); |
| 50 | this.vdcs = ImmutableMap.copyOf(checkNotNull(vdcs, "vdcs")); |
| 51 | this.tasksLists = ImmutableMap.copyOf(checkNotNull(tasksLists, "tasksLists")); |
| 52 | this.keys = checkNotNull(keys, "keys"); |
| 53 | } |
| 54 | |
| 55 | @Override |
| 56 | public String getDescription() { |
| 57 | return description; |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public Map<String, ReferenceType> getCatalogs() { |
| 62 | return catalogs; |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public Map<String, ReferenceType> getVDCs() { |
| 67 | return vdcs; |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public int hashCode() { |
| 72 | final int prime = 31; |
| 73 | int result = super.hashCode(); |
| 74 | result = prime * result + ((catalogs == null) ? 0 : catalogs.hashCode()); |
| 75 | result = prime * result + ((description == null) ? 0 : description.hashCode()); |
| 76 | result = prime * result + ((keys == null) ? 0 : keys.hashCode()); |
| 77 | result = prime * result + ((tasksLists == null) ? 0 : tasksLists.hashCode()); |
| 78 | result = prime * result + ((vdcs == null) ? 0 : vdcs.hashCode()); |
| 79 | return result; |
| 80 | } |
| 81 | |
| 82 | @Override |
| 83 | public boolean equals(Object obj) { |
| 84 | if (this == obj) |
| 85 | return true; |
| 86 | if (!super.equals(obj)) |
| 87 | return false; |
| 88 | if (getClass() != obj.getClass()) |
| 89 | return false; |
| 90 | OrgImpl other = (OrgImpl) obj; |
| 91 | if (catalogs == null) { |
| 92 | if (other.catalogs != null) |
| 93 | return false; |
| 94 | } else if (!catalogs.equals(other.catalogs)) |
| 95 | return false; |
| 96 | if (description == null) { |
| 97 | if (other.description != null) |
| 98 | return false; |
| 99 | } else if (!description.equals(other.description)) |
| 100 | return false; |
| 101 | if (keys == null) { |
| 102 | if (other.keys != null) |
| 103 | return false; |
| 104 | } else if (!keys.equals(other.keys)) |
| 105 | return false; |
| 106 | if (tasksLists == null) { |
| 107 | if (other.tasksLists != null) |
| 108 | return false; |
| 109 | } else if (!tasksLists.equals(other.tasksLists)) |
| 110 | return false; |
| 111 | if (vdcs == null) { |
| 112 | if (other.vdcs != null) |
| 113 | return false; |
| 114 | } else if (!vdcs.equals(other.vdcs)) |
| 115 | return false; |
| 116 | return true; |
| 117 | } |
| 118 | |
| 119 | @Override |
| 120 | public int compareTo(ReferenceType o) { |
| 121 | return (this == o) ? 0 : getHref().compareTo(o.getHref()); |
| 122 | } |
| 123 | |
| 124 | @Override |
| 125 | public String toString() { |
| 126 | return "[href=" + getHref() + ", name=" + getName() + ", type=" + getType() + ", description=" + description |
| 127 | + ", catalogs=" + catalogs + ", tasksLists=" + tasksLists + ", vdcs=" + vdcs + ", keys=" + keys + "]"; |
| 128 | } |
| 129 | |
| 130 | @Override |
| 131 | public Map<String, ReferenceType> getTasksLists() { |
| 132 | return tasksLists; |
| 133 | } |
| 134 | |
| 135 | @Override |
| 136 | public ReferenceType getKeys() { |
| 137 | return keys; |
| 138 | } |
| 139 | |
| 140 | } |