001/* 002 * Copyright 2010-2014 Ning, Inc. 003 * Copyright 2014-2015 The Billing Project, LLC 004 * 005 * The Billing Project licenses this file to you under the Apache License, version 2.0 006 * (the "License"); you may not use this file except in compliance with the 007 * License. You may obtain a copy of the License at: 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 013 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 014 * License for the specific language governing permissions and limitations 015 * under the License. 016 */ 017 018package com.ning.billing.recurly.model; 019 020import java.util.Objects; 021 022import javax.xml.bind.annotation.XmlElement; 023import javax.xml.bind.annotation.XmlRootElement; 024 025@XmlRootElement(name = "tier") 026public class Tier extends RecurlyObject { 027 028 @XmlElement(name = "unit_amount_in_cents") 029 private RecurlyUnitCurrency unitAmountInCents; 030 031 @XmlElement(name = "ending_quantity") 032 private Integer endingQuantity; 033 034 public RecurlyUnitCurrency getUnitAmountInCents() { 035 return unitAmountInCents; 036 } 037 038 public void setUnitAmountInCents(final RecurlyUnitCurrency unitAmountInCents) { 039 this.unitAmountInCents = unitAmountInCents; 040 } 041 042 public Integer getEndingQuantity() { 043 return endingQuantity; 044 } 045 046 public void setEndingQuantity(final Object endingQuantity) { 047 this.endingQuantity = integerOrNull(endingQuantity); 048 } 049 050 @Override 051 public String toString() { 052 final StringBuilder sb = new StringBuilder("Tier{"); 053 sb.append("unitAmountInCents=").append(unitAmountInCents); 054 sb.append(", endingQuantity=").append(endingQuantity); 055 sb.append('}'); 056 return sb.toString(); 057 } 058 059 @Override 060 public boolean equals(final Object o) { 061 if (this == o) return true; 062 if (o == null || getClass() != o.getClass()) return false; 063 064 final Tier tier = (Tier) o; 065 066 if (unitAmountInCents != null ? !unitAmountInCents.equals(tier.unitAmountInCents) : tier.unitAmountInCents != null) { 067 return false; 068 } 069 if (endingQuantity != null ? !endingQuantity.equals(tier.endingQuantity) : tier.endingQuantity != null) { 070 return false; 071 } 072 return true; 073 } 074 075 @Override 076 public int hashCode() { 077 return Objects.hash( 078 unitAmountInCents, 079 endingQuantity 080 ); 081 } 082}