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 javax.xml.bind.annotation.XmlElement;
021import javax.xml.bind.annotation.XmlRootElement;
022import javax.xml.bind.annotation.XmlTransient;
023
024import org.joda.time.DateTime;
025
026import com.google.common.base.Objects;
027
028@XmlRootElement(name = "shipping_method")
029public class ShippingMethod extends RecurlyObject {
030
031    @XmlTransient
032    public static final String SHIPPING_METHOD_RESOURCE = "/shipping_methods";
033
034    @XmlElement(name = "code")
035    private String code;
036
037    @XmlElement(name = "name")
038    private String name;
039
040    @XmlElement(name = "accounting_code")
041    private String accountingCode;
042
043    @XmlElement(name = "tax_code")
044    private String taxCode;
045
046    @XmlElement(name = "created_at")
047    private DateTime createdAt;
048
049    @XmlElement(name = "updated_at")
050    private DateTime updatedAt;
051
052    public String getCode() {
053        return code;
054    }
055
056    public void setCode(final Object code) {
057        this.code = stringOrNull(code);
058    }
059
060    public String getName() {
061        return name;
062    }
063
064    public void setName(final Object name) {
065        this.name = stringOrNull(name);
066    }
067
068    public String getAccountingCode() {
069        return accountingCode;
070    }
071
072    public void setAccountingCode(final Object accountingCode) {
073        this.accountingCode = stringOrNull(accountingCode);
074    }
075
076    public String getTaxCode() {
077        return taxCode;
078    }
079
080    public void setTaxCode(final Object taxCode) {
081        this.taxCode = stringOrNull(taxCode);
082    }
083
084    public DateTime getCreatedAt() {
085        return createdAt;
086    }
087
088    public void setCreatedAt(final Object createdAt) {
089        this.createdAt = dateTimeOrNull(createdAt);
090    }
091
092    public DateTime getUpdatedAt() {
093        return updatedAt;
094    }
095
096    public void setUpdatedAt(final Object updatedAt) {
097        this.updatedAt = dateTimeOrNull(updatedAt);
098    }
099
100    @Override
101    public String toString() {
102        final StringBuilder sb = new StringBuilder();
103        sb.append("ShippingMethod");
104        sb.append("{code=").append(code);
105        sb.append(", name=").append(name);
106        sb.append(", accountingCode=").append(accountingCode);
107        sb.append(", taxCode=").append(taxCode);
108        sb.append(", createdAt=").append(createdAt);
109        sb.append(", updatedAt=").append(updatedAt);
110        sb.append('}');
111        return sb.toString();
112    }
113
114    @Override
115    public boolean equals(final Object o) {
116        if (this == o) return true;
117        if (o == null || getClass() != o.getClass()) return false;
118
119        final ShippingMethod that = (ShippingMethod) o;
120
121        if (code != null ? !code.equals(that.code) : that.code != null) {
122            return false;
123        }
124        if (name != null ? !name.equals(that.name) : that.name != null) {
125            return false;
126        }
127        if (accountingCode != null ? !accountingCode.equals(that.accountingCode) : that.accountingCode != null) {
128            return false;
129        }
130        if (taxCode != null ? !taxCode.equals(that.taxCode) : that.taxCode != null) {
131            return false;
132        }
133        if (createdAt != null ? createdAt.compareTo(that.createdAt) != 0 : that.createdAt != null) {
134            return false;
135        }
136        if (updatedAt != null ? updatedAt.compareTo(that.updatedAt) != 0 : that.updatedAt != null) {
137            return false;
138        }
139
140        return true;
141    }
142
143    @Override
144    public int hashCode() {
145        return Objects.hashCode(
146            code,
147            name,
148            accountingCode,
149            taxCode,
150            createdAt,
151            updatedAt
152        );
153    }
154}