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 @XmlElement(name = "add_on_source") 038 private String addOnSource; 039 040 public Integer getUnitAmountInCents() { 041 return unitAmountInCents; 042 } 043 044 public void setUnitAmountInCents(final Object unitAmountInCents) { 045 this.unitAmountInCents = integerOrNull(unitAmountInCents); 046 } 047 048 public Integer getQuantity() { 049 return quantity; 050 } 051 052 public void setQuantity(final Object quantity) { 053 this.quantity = integerOrNull(quantity); 054 } 055 056 public String getGatewayCode() { 057 return gatewayCode; 058 } 059 060 public void setGatewayCode(final Object gatewayCode) { 061 this.gatewayCode = stringOrNull(gatewayCode); 062 } 063 064 public String getAddOnSource() { 065 return addOnSource; 066 } 067 068 public void setAddOnSource(final Object addOnSource) { 069 this.addOnSource = stringOrNull(addOnSource); 070 } 071 072 @Override 073 public String toString() { 074 final StringBuilder sb = new StringBuilder("SubscriptionAddOn{"); 075 sb.append("unitAmountInCents=").append(unitAmountInCents); 076 sb.append(", quantity=").append(quantity); 077 sb.append(", gatewayCode=").append(gatewayCode); 078 sb.append(", addOnSource=").append(addOnSource); 079 sb.append('}'); 080 return sb.toString(); 081 } 082 083 @Override 084 public boolean equals(final Object o) { 085 if (this == o) return true; 086 if (o == null || getClass() != o.getClass()) return false; 087 088 final SubscriptionAddOn addOn = (SubscriptionAddOn) o; 089 090 if (quantity != null ? !quantity.equals(addOn.quantity) : addOn.quantity != null) { 091 return false; 092 } 093 if (unitAmountInCents != null ? !unitAmountInCents.equals(addOn.unitAmountInCents) : addOn.unitAmountInCents != null) { 094 return false; 095 } 096 if (gatewayCode != null ? !gatewayCode.equals(addOn.gatewayCode) : addOn.gatewayCode != null) { 097 return false; 098 } 099 if (addOnSource != null ? !addOnSource.equals(addOn.addOnSource) : addOn.addOnSource != null) { 100 return false; 101 } 102 103 return true; 104 } 105 106 @Override 107 public int hashCode() { 108 return Objects.hashCode( 109 unitAmountInCents, 110 quantity, 111 gatewayCode, 112 addOnSource 113 ); 114 } 115}