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 com.google.common.base.Objects; 021 022import javax.xml.bind.annotation.XmlElement; 023import javax.xml.bind.annotation.XmlElementWrapper; 024import javax.xml.bind.annotation.XmlRootElement; 025 026@XmlRootElement(name = "invoice_collection") 027public class InvoiceCollection extends RecurlyObject { 028 029 @XmlElement(name = "charge_invoice") 030 private Invoice chargeInvoice; 031 032 @XmlElementWrapper(name = "credit_invoices") 033 @XmlElement(name = "credit_invoice") 034 private CreditInvoices creditInvoices; 035 036 public void setChargeInvoice(final Invoice chargeInvoice) { 037 this.chargeInvoice = chargeInvoice; 038 } 039 040 public Invoice getChargeInvoice() { 041 return this.chargeInvoice; 042 } 043 044 public void setCreditInvoices(final CreditInvoices creditInvoices) { 045 this.creditInvoices = creditInvoices; 046 } 047 048 public CreditInvoices getCreditInvoices() { 049 return this.creditInvoices; 050 } 051 052 @Override 053 public String toString() { 054 final StringBuilder sb = new StringBuilder("InvoiceCollection{"); 055 sb.append("chargeInvoice='").append(chargeInvoice).append('\''); 056 sb.append(", creditInvoices='").append(creditInvoices).append('\''); 057 sb.append('}'); 058 return sb.toString(); 059 } 060 061 @Override 062 public boolean equals(final Object o) { 063 if (this == o) return true; 064 if (o == null || getClass() != o.getClass()) return false; 065 066 final InvoiceCollection collection = (InvoiceCollection) o; 067 068 if (chargeInvoice != null ? !chargeInvoice.equals(collection.chargeInvoice) : collection.chargeInvoice != null) { 069 return false; 070 } 071 if (creditInvoices != null ? !creditInvoices.equals(collection.creditInvoices) : collection.creditInvoices != null) { 072 return false; 073 } 074 075 return true; 076 } 077 078 @Override 079 public int hashCode() { 080 return Objects.hashCode( 081 chargeInvoice, 082 creditInvoices 083 ); 084 } 085}