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.push.invoice;
018
019import com.ning.billing.recurly.model.Invoice;
020import org.joda.time.DateTime;
021import java.util.List;
022
023import javax.xml.bind.annotation.XmlElement;
024import javax.xml.bind.annotation.XmlElementWrapper;
025import javax.xml.bind.annotation.XmlList;
026
027public class PushInvoice extends Invoice {
028
029    @XmlList
030    @XmlElementWrapper(name = "subscription_ids")
031    private List<String> subscriptionIds;
032
033    @XmlElement(name = "subscription_id")
034    private String subscriptionId;
035
036    @XmlElement(name = "invoice_number_prefix")
037    private String invoiceNumberPrefix;
038
039    @XmlElement(name = "date")
040    private DateTime date;
041
042    @XmlElement(name = "closed_at")
043    private DateTime closedAt;
044
045    @XmlElement(name = "dunning_events_count")
046    private Integer dunningEventsCount;
047
048    @XmlElement(name = "final_dunning_event")
049    private Boolean isFinalDunningEvent;
050
051    public List<String> getSubscriptionIds() {
052        return subscriptionIds;
053    }
054
055    public void setSubscriptionIds(final List<String> subscriptionIds) {
056        this.subscriptionIds = subscriptionIds;
057    }
058
059    /**
060     * @deprecated Use getSubscriptionIds instead
061     */
062    @Deprecated
063    public String getSubscriptionId() {
064        return subscriptionId;
065    }
066
067    /**
068     * @deprecated Use setSubscriptionIds instead
069     */
070    @Deprecated
071    public void setSubscriptionId(final Object subscriptionId) {
072        this.subscriptionId = stringOrNull(subscriptionId);
073    }
074
075    public String getInvoiceNumberPrefix() {
076        return invoiceNumberPrefix;
077    }
078
079    public void setInvoiceNumberPrefix(final Object invoiceNumberPrefix) {
080        this.invoiceNumberPrefix = stringOrNull(invoiceNumberPrefix);
081    }
082
083    public DateTime getDate() {
084        return date;
085    }
086
087    public void setDate(final Object date) {
088        this.date = dateTimeOrNull(date);
089    }
090
091    public DateTime getClosedAt() {
092        return closedAt;
093    }
094
095    public void setClosedAt(final Object closedAt) {
096        this.closedAt = dateTimeOrNull(closedAt);
097    }
098
099    public Integer getDunningEventsCount() {
100       return dunningEventsCount;
101    }
102
103    public void setDunningEventsCount(final Object dunningEventsCount) {
104       this.dunningEventsCount = integerOrNull(dunningEventsCount);
105    }
106
107    public Boolean isFinalDunningEvent() {
108       return isFinalDunningEvent;
109    }
110
111    public void setIsFinalDunningEvent(final Object isFinalDunningEvent) {
112       this.isFinalDunningEvent = booleanOrNull(isFinalDunningEvent);
113    }
114
115    @Override
116    public boolean equals(final Object o) {
117        if (this == o) {
118            return true;
119        }
120        if (!(o instanceof PushInvoice)) {
121            return false;
122        }
123        if (!super.equals(o)) {
124            return false;
125        }
126
127        final PushInvoice that = (PushInvoice) o;
128
129        if (subscriptionIds != null ? !subscriptionIds.equals(that.subscriptionIds) : that.subscriptionIds != null) {
130            return false;
131        }
132
133        if (subscriptionId != null ? !subscriptionId.equals(that.subscriptionId) : that.subscriptionId != null) {
134            return false;
135        }
136
137        if (invoiceNumberPrefix != null ? !invoiceNumberPrefix.equals(that.invoiceNumberPrefix) : that.invoiceNumberPrefix != null) {
138            return false;
139        }
140
141        if (date != null ? !date.equals(that.date) : that.date != null) {
142            return false;
143        }
144
145        if (closedAt != null ? !closedAt.equals(that.closedAt) : that.closedAt != null) {
146            return false;
147        }
148
149        return true;
150    }
151
152    @Override
153    public int hashCode() {
154        int result = super.hashCode();
155        result = 31 * result + (subscriptionIds != null ? subscriptionIds.hashCode() : 0);
156        result = 31 * result + (subscriptionId != null ? subscriptionId.hashCode() : 0);
157        result = 31 * result + (invoiceNumberPrefix != null ? invoiceNumberPrefix.hashCode() : 0);
158        result = 31 * result + (date != null ? date.hashCode() : 0);
159        result = 31 * result + (closedAt != null ? closedAt.hashCode() : 0);
160        return result;
161    }
162}