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 javax.xml.bind.annotation.XmlElement; 021import javax.xml.bind.annotation.XmlRootElement; 022 023import com.google.common.base.Objects; 024 025@XmlRootElement(name = "subscription_add_on") 026public class SubscriptionAddOn extends AbstractAddOn { 027 028 @XmlElement(name = "unit_amount_in_cents") 029 private Integer unitAmountInCents; 030 031 @XmlElement(name = "quantity") 032 private Integer quantity; 033 034 @XmlElement(name = "gateway_code") 035 private String gatewayCode; 036 037 public Integer getUnitAmountInCents() { 038 return unitAmountInCents; 039 } 040 041 public void setUnitAmountInCents(final Object unitAmountInCents) { 042 this.unitAmountInCents = integerOrNull(unitAmountInCents); 043 } 044 045 public Integer getQuantity() { 046 return quantity; 047 } 048 049 public void setQuantity(final Object quantity) { 050 this.quantity = integerOrNull(quantity); 051 } 052 053 public String getGatewayCode() { 054 return gatewayCode; 055 } 056 057 public void setGatewayCode(final Object gatewayCode) { 058 this.gatewayCode = stringOrNull(gatewayCode); 059 } 060 061 @Override 062 public String toString() { 063 final StringBuilder sb = new StringBuilder("SubscriptionAddOn{"); 064 sb.append("unitAmountInCents=").append(unitAmountInCents); 065 sb.append(", quantity=").append(quantity); 066 sb.append(", gatewayCode=").append(gatewayCode); 067 sb.append('}'); 068 return sb.toString(); 069 } 070 071 @Override 072 public boolean equals(final Object o) { 073 if (this == o) return true; 074 if (o == null || getClass() != o.getClass()) return false; 075 076 final SubscriptionAddOn addOn = (SubscriptionAddOn) o; 077 078 if (quantity != null ? !quantity.equals(addOn.quantity) : addOn.quantity != null) { 079 return false; 080 } 081 if (unitAmountInCents != null ? !unitAmountInCents.equals(addOn.unitAmountInCents) : addOn.unitAmountInCents != null) { 082 return false; 083 } 084 if (gatewayCode != null ? !gatewayCode.equals(addOn.gatewayCode) : addOn.gatewayCode != null) { 085 return false; 086 } 087 088 return true; 089 } 090 091 @Override 092 public int hashCode() { 093 return Objects.hashCode( 094 unitAmountInCents, 095 quantity, 096 gatewayCode 097 ); 098 } 099}