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.push.subscription;
019
020import com.google.common.base.Objects;
021
022import javax.xml.bind.annotation.XmlElement;
023
024import com.ning.billing.recurly.model.Subscription;
025
026import org.joda.time.DateTime;
027
028public class PushSubscription extends Subscription {
029
030    @XmlElement(name = "total_amount_in_cents")
031    private Integer totalAmountInCents;
032
033    @XmlElement(name = "resume_at")
034    private DateTime resumeAt;
035
036    public Integer getTotalAmountInCents() {
037        return totalAmountInCents;
038    }
039
040    public void setTotalAmountInCents(final Object totalAmountInCents) {
041        this.totalAmountInCents = integerOrNull(totalAmountInCents);
042    }
043
044    public DateTime getResumeAt() {
045        return resumeAt;
046    }
047
048    public void setResumeAt(final Object resumeAt) {
049        this.resumeAt = dateTimeOrNull(resumeAt);
050    }
051
052    @Override
053    public boolean equals(final Object o) {
054        if (this == o) {
055            return true;
056        }
057        if (!(o instanceof PushSubscription)) {
058            return false;
059        }
060        if (!super.equals(o)) {
061            return false;
062        }
063
064        final PushSubscription that = (PushSubscription) o;
065
066        if (totalAmountInCents != null ? !totalAmountInCents.equals(that.totalAmountInCents) : that.totalAmountInCents != null) {
067            return false;
068        }
069
070        if (resumeAt != null ? !resumeAt.equals(that.resumeAt) : that.resumeAt != null) {
071            return false;
072        }
073
074        return true;
075    }
076
077    @Override
078    public int hashCode() {
079        return Objects.hashCode(
080            totalAmountInCents,
081            resumeAt
082        );
083    }
084}