| 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.gogrid.domain; |
| 20 | |
| 21 | import java.util.Date; |
| 22 | import java.util.Set; |
| 23 | |
| 24 | import com.google.common.primitives.Longs; |
| 25 | import com.google.gson.annotations.SerializedName; |
| 26 | |
| 27 | /** |
| 28 | * @author Oleksiy Yarmula |
| 29 | */ |
| 30 | public class ServerImage implements Comparable<ServerImage> { |
| 31 | |
| 32 | private long id; |
| 33 | private String name; |
| 34 | private String friendlyName; |
| 35 | private String description; |
| 36 | private Option os; |
| 37 | private Option architecture; |
| 38 | private ServerImageType type; |
| 39 | private ServerImageState state; |
| 40 | private double price; |
| 41 | private String location; |
| 42 | private boolean isActive; |
| 43 | private boolean isPublic; |
| 44 | private Date createdTime; |
| 45 | private Date updatedTime; |
| 46 | @SerializedName("billingtokens") |
| 47 | private Set<BillingToken> billingTokens; |
| 48 | private Customer owner; |
| 49 | |
| 50 | /** |
| 51 | * A no-args constructor is required for deserialization |
| 52 | */ |
| 53 | public ServerImage() { |
| 54 | } |
| 55 | |
| 56 | public ServerImage(long id, String name, String friendlyName, String description, Option os, |
| 57 | Option architecture, ServerImageType type, ServerImageState state, double price, |
| 58 | String location, boolean active, boolean aPublic, Date createdTime, Date updatedTime, |
| 59 | Set<BillingToken> billingTokens, Customer owner) { |
| 60 | this.id = id; |
| 61 | this.name = name; |
| 62 | this.friendlyName = friendlyName; |
| 63 | this.description = description; |
| 64 | this.os = os; |
| 65 | this.architecture = architecture; |
| 66 | this.type = type; |
| 67 | this.state = state; |
| 68 | this.price = price; |
| 69 | this.location = location; |
| 70 | isActive = active; |
| 71 | isPublic = aPublic; |
| 72 | this.createdTime = createdTime; |
| 73 | this.updatedTime = updatedTime; |
| 74 | this.billingTokens = billingTokens; |
| 75 | this.owner = owner; |
| 76 | } |
| 77 | |
| 78 | public long getId() { |
| 79 | return id; |
| 80 | } |
| 81 | |
| 82 | public String getName() { |
| 83 | return name; |
| 84 | } |
| 85 | |
| 86 | public String getFriendlyName() { |
| 87 | return friendlyName; |
| 88 | } |
| 89 | |
| 90 | public String getDescription() { |
| 91 | if (description == null) |
| 92 | return ""; |
| 93 | return description; |
| 94 | } |
| 95 | |
| 96 | public Option getOs() { |
| 97 | return os; |
| 98 | } |
| 99 | |
| 100 | public Option getArchitecture() { |
| 101 | return architecture; |
| 102 | } |
| 103 | |
| 104 | public ServerImageType getType() { |
| 105 | return type; |
| 106 | } |
| 107 | |
| 108 | public ServerImageState getState() { |
| 109 | return state; |
| 110 | } |
| 111 | |
| 112 | public double getPrice() { |
| 113 | return price; |
| 114 | } |
| 115 | |
| 116 | public String getLocation() { |
| 117 | return location; |
| 118 | } |
| 119 | |
| 120 | public boolean isActive() { |
| 121 | return isActive; |
| 122 | } |
| 123 | |
| 124 | public boolean isPublic() { |
| 125 | return isPublic; |
| 126 | } |
| 127 | |
| 128 | public Date getCreatedTime() { |
| 129 | return createdTime; |
| 130 | } |
| 131 | |
| 132 | public Date getUpdatedTime() { |
| 133 | return updatedTime; |
| 134 | } |
| 135 | |
| 136 | public Set<BillingToken> getBillingTokens() { |
| 137 | return billingTokens; |
| 138 | } |
| 139 | |
| 140 | public Customer getOwner() { |
| 141 | return owner; |
| 142 | } |
| 143 | |
| 144 | @Override |
| 145 | public boolean equals(Object o) { |
| 146 | if (this == o) |
| 147 | return true; |
| 148 | if (o == null || getClass() != o.getClass()) |
| 149 | return false; |
| 150 | |
| 151 | ServerImage that = (ServerImage) o; |
| 152 | |
| 153 | if (id != that.id) |
| 154 | return false; |
| 155 | if (isActive != that.isActive) |
| 156 | return false; |
| 157 | if (isPublic != that.isPublic) |
| 158 | return false; |
| 159 | if (Double.compare(that.price, price) != 0) |
| 160 | return false; |
| 161 | if (architecture != null ? !architecture.equals(that.architecture) |
| 162 | : that.architecture != null) |
| 163 | return false; |
| 164 | if (billingTokens != null ? !billingTokens.equals(that.billingTokens) |
| 165 | : that.billingTokens != null) |
| 166 | return false; |
| 167 | if (!createdTime.equals(that.createdTime)) |
| 168 | return false; |
| 169 | if (description != null ? !description.equals(that.description) : that.description != null) |
| 170 | return false; |
| 171 | if (friendlyName != null ? !friendlyName.equals(that.friendlyName) |
| 172 | : that.friendlyName != null) |
| 173 | return false; |
| 174 | if (location != null ? !location.equals(that.location) : that.location != null) |
| 175 | return false; |
| 176 | if (!name.equals(that.name)) |
| 177 | return false; |
| 178 | if (!os.equals(that.os)) |
| 179 | return false; |
| 180 | if (owner != null ? !owner.equals(that.owner) : that.owner != null) |
| 181 | return false; |
| 182 | if (!state.equals(that.state)) |
| 183 | return false; |
| 184 | if (!type.equals(that.type)) |
| 185 | return false; |
| 186 | if (updatedTime != null ? !updatedTime.equals(that.updatedTime) : that.updatedTime != null) |
| 187 | return false; |
| 188 | |
| 189 | return true; |
| 190 | } |
| 191 | |
| 192 | @Override |
| 193 | public int hashCode() { |
| 194 | int result; |
| 195 | long temp; |
| 196 | result = (int) (id ^ (id >>> 32)); |
| 197 | result = 31 * result + name.hashCode(); |
| 198 | result = 31 * result + (friendlyName != null ? friendlyName.hashCode() : 0); |
| 199 | result = 31 * result + (description != null ? description.hashCode() : 0); |
| 200 | result = 31 * result + os.hashCode(); |
| 201 | result = 31 * result + type.hashCode(); |
| 202 | result = 31 * result + state.hashCode(); |
| 203 | temp = price != +0.0d ? Double.doubleToLongBits(price) : 0L; |
| 204 | result = 31 * result + (int) (temp ^ (temp >>> 32)); |
| 205 | result = 31 * result + (location != null ? location.hashCode() : 0); |
| 206 | result = 31 * result + (isActive ? 1 : 0); |
| 207 | result = 31 * result + (isPublic ? 1 : 0); |
| 208 | result = 31 * result + createdTime.hashCode(); |
| 209 | result = 31 * result + (updatedTime != null ? updatedTime.hashCode() : 0); |
| 210 | result = 31 * result + (billingTokens != null ? billingTokens.hashCode() : 0); |
| 211 | result = 31 * result + (owner != null ? owner.hashCode() : 0); |
| 212 | return result; |
| 213 | } |
| 214 | |
| 215 | @Override |
| 216 | public int compareTo(ServerImage o) { |
| 217 | return Longs.compare(id, o.getId()); |
| 218 | } |
| 219 | |
| 220 | @Override |
| 221 | public String toString() { |
| 222 | return "ServerImage{" + "id=" + id + ", name='" + name + '\'' + ", friendlyName='" |
| 223 | + friendlyName + '\'' + ", description='" + description + '\'' + ", os=" + os |
| 224 | + ", architecture=" + architecture + ", type=" + type + ", state=" + state |
| 225 | + ", price=" + price + ", location='" + location + '\'' + ", isActive=" + isActive |
| 226 | + ", isPublic=" + isPublic + ", createdTime=" + createdTime + ", updatedTime=" |
| 227 | + updatedTime + ", billingTokens=" + billingTokens + ", owner=" + owner + '}'; |
| 228 | } |
| 229 | } |