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