| 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.gogrid.domain; |
| 20 | |
| 21 | import com.google.common.primitives.Longs; |
| 22 | |
| 23 | /** |
| 24 | * @author Oleksiy Yarmula |
| 25 | */ |
| 26 | public class BillingToken implements Comparable<BillingToken> { |
| 27 | |
| 28 | private long id; |
| 29 | private String name; |
| 30 | private double price; |
| 31 | |
| 32 | /** |
| 33 | * A no-args constructor is required for deserialization |
| 34 | */ |
| 35 | public BillingToken() { |
| 36 | } |
| 37 | |
| 38 | public BillingToken(long id, String name, double price) { |
| 39 | this.id = id; |
| 40 | this.name = name; |
| 41 | this.price = price; |
| 42 | } |
| 43 | |
| 44 | public long getId() { |
| 45 | return id; |
| 46 | } |
| 47 | |
| 48 | public String getName() { |
| 49 | return name; |
| 50 | } |
| 51 | |
| 52 | public double getPrice() { |
| 53 | return price; |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public boolean equals(Object o) { |
| 58 | if (this == o) return true; |
| 59 | if (o == null || getClass() != o.getClass()) return false; |
| 60 | |
| 61 | BillingToken that = (BillingToken) o; |
| 62 | |
| 63 | if (id != that.id) return false; |
| 64 | if (Double.compare(that.price, price) != 0) return false; |
| 65 | if (!name.equals(that.name)) return false; |
| 66 | |
| 67 | return true; |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public int hashCode() { |
| 72 | int result; |
| 73 | long temp; |
| 74 | result = (int) (id ^ (id >>> 32)); |
| 75 | result = 31 * result + name.hashCode(); |
| 76 | temp = price != +0.0d ? Double.doubleToLongBits(price) : 0L; |
| 77 | result = 31 * result + (int) (temp ^ (temp >>> 32)); |
| 78 | return result; |
| 79 | } |
| 80 | |
| 81 | @Override |
| 82 | public int compareTo(BillingToken o) { |
| 83 | return Longs.compare(id, o.getId()); |
| 84 | } |
| 85 | |
| 86 | @Override |
| 87 | public String toString() { |
| 88 | return "BillingToken{" + |
| 89 | "id=" + id + |
| 90 | ", name='" + name + '\'' + |
| 91 | ", price=" + price + |
| 92 | '}'; |
| 93 | } |
| 94 | } |