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;
024
025public class SubscriptionNotes extends AbstractSubscription {
026
027    @XmlElement(name = "terms_and_conditions")
028    private String termsAndConditions;
029    
030    @XmlElement(name = "customer_notes")
031    private String customerNotes;
032    
033    @XmlElement(name = "vat_reverse_charge_notes")
034    private String vatReverseChargeNotes;
035
036    @XmlElement(name = "gateway_code")
037    private String gatewayCode;
038
039    @XmlElementWrapper(name = "custom_fields")
040    @XmlElement(name = "custom_field")
041    private CustomFields customFields;
042
043    public String getTermsAndConditions() {
044        return termsAndConditions;
045    }
046
047    public void setTermsAndConditions(final Object termsAndConditions) {
048        this.termsAndConditions = stringOrNull(termsAndConditions);
049    }
050    
051    public String getCustomerNotes() {
052        return customerNotes;
053    }
054
055    public void setCustomerNotes(final Object customerNotes) {
056        this.customerNotes = stringOrNull(customerNotes);
057    }
058    
059    public String getVatReverseChargeNotes() {
060        return vatReverseChargeNotes;
061    }
062
063    public void setVatReverseChargeNotes(final Object getVatReverseChargeNotes) {
064        this.vatReverseChargeNotes = stringOrNull(vatReverseChargeNotes);
065    }
066    
067    public String getGatewayCode() {
068        return gatewayCode;
069    }
070
071    public void setGatewayCode(final Object gatewayCode) {
072        this.gatewayCode = stringOrNull(gatewayCode);
073    }
074
075    public CustomFields getCustomFields() {
076        return customFields;
077    }
078
079    public void setCustomFields(final CustomFields customFields) {
080        this.customFields = customFields;
081    }
082
083    @Override
084    public String toString() {
085        final StringBuilder sb = new StringBuilder("Subscription{");
086        sb.append("termsAndConditions=").append(termsAndConditions).append('\'');
087        sb.append(", customerNotes=").append(customerNotes).append('\'');
088        sb.append(", vatReverseChargeNotes=").append(vatReverseChargeNotes).append('\'');
089        sb.append(", gatewayCode=").append(gatewayCode).append('\'');
090        sb.append(", customFields=").append(customFields);
091        sb.append('}');
092        return sb.toString();
093    }
094
095    @Override
096    public boolean equals(final Object o) {
097        if (this == o) return true;
098        if (o == null || getClass() != o.getClass()) return false;
099
100        final SubscriptionNotes that = (SubscriptionNotes) o;
101
102        if (termsAndConditions != null ? !termsAndConditions.equals(that.termsAndConditions) : that.termsAndConditions != null) {
103            return false;
104        }
105        if (customerNotes != null ? !customerNotes.equals(that.customerNotes) : that.customerNotes != null) {
106            return false;
107        }
108        if (customFields != null ? !customFields.equals(that.customFields) : that.customFields != null) {
109            return false;
110        }
111        if (vatReverseChargeNotes != null ? !vatReverseChargeNotes.equals(that.vatReverseChargeNotes) : that.vatReverseChargeNotes != null) {
112            return false;
113        }
114        if (gatewayCode != null ? !gatewayCode.equals(that.gatewayCode) : that.gatewayCode != null) {
115            return false;
116        }
117
118        return true;
119    }
120
121    @Override
122    public int hashCode() {
123        return Objects.hashCode(
124                termsAndConditions,
125                customerNotes,
126                vatReverseChargeNotes,
127                customFields,
128                gatewayCode
129        );
130    }
131}