| 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 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 obj) { |
| 58 | if (this == obj) |
| 59 | return true; |
| 60 | if (obj == null) |
| 61 | return false; |
| 62 | if (getClass() != obj.getClass()) |
| 63 | return false; |
| 64 | BillingToken other = (BillingToken) obj; |
| 65 | if (id != other.id) |
| 66 | return false; |
| 67 | if (name == null) { |
| 68 | if (other.name != null) |
| 69 | return false; |
| 70 | } else if (!name.equals(other.name)) |
| 71 | return false; |
| 72 | if (Double.doubleToLongBits(price) != Double.doubleToLongBits(other.price)) |
| 73 | return false; |
| 74 | return true; |
| 75 | } |
| 76 | |
| 77 | @Override |
| 78 | public int hashCode() { |
| 79 | final int prime = 31; |
| 80 | int result = 1; |
| 81 | result = prime * result + (int) (id ^ (id >>> 32)); |
| 82 | result = prime * result + ((name == null) ? 0 : name.hashCode()); |
| 83 | long temp; |
| 84 | temp = Double.doubleToLongBits(price); |
| 85 | result = prime * result + (int) (temp ^ (temp >>> 32)); |
| 86 | return result; |
| 87 | } |
| 88 | |
| 89 | @Override |
| 90 | public int compareTo(BillingToken o) { |
| 91 | return Longs.compare(id, o.getId()); |
| 92 | } |
| 93 | |
| 94 | @Override |
| 95 | public String toString() { |
| 96 | return "BillingToken{" + "id=" + id + ", name='" + name + '\'' + ", price=" + price + '}'; |
| 97 | } |
| 98 | } |