/**
 * Licensed to jclouds, Inc. (jclouds) under one or more
 * contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  jclouds licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.jclouds.gogrid.domain;

import com.google.common.primitives.Longs;

/**
 * @author Oleksiy Yarmula
 */
public class BillingToken implements Comparable<BillingToken> {

   private long id;
   private String name;
   private double price;

   /**
    * A no-args constructor is required for deserialization
    */
   public BillingToken() {
   }

   public BillingToken(long id, String name, double price) {
      this.id = id;
      this.name = name;
      this.price = price;
   }

   public long getId() {
      return id;
   }

   public String getName() {
      return name;
   }

   public double getPrice() {
      return price;
   }

   @Override
   public boolean equals(Object obj) {
      if (this == obj)
         return true;
      if (obj == null)
         return false;
      if (getClass() != obj.getClass())
         return false;
      BillingToken other = (BillingToken) obj;
      if (id != other.id)
         return false;
      if (name == null) {
         if (other.name != null)
            return false;
      } else if (!name.equals(other.name))
         return false;
      if (Double.doubleToLongBits(price) != Double.doubleToLongBits(other.price))
         return false;
      return true;
   }

   @Override
   public int hashCode() {
      final int prime = 31;
      int result = 1;
      result = prime * result + (int) (id ^ (id >>> 32));
      result = prime * result + ((name == null) ? 0 : name.hashCode());
      long temp;
      temp = Double.doubleToLongBits(price);
      result = prime * result + (int) (temp ^ (temp >>> 32));
      return result;
   }

   @Override
   public int compareTo(BillingToken o) {
      return Longs.compare(id, o.getId());
   }

   @Override
   public String toString() {
      return "BillingToken{" + "id=" + id + ", name='" + name + '\'' + ", price=" + price + '}';
   }
}
