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;
018
019import javax.xml.bind.annotation.XmlElement;
020import javax.xml.bind.annotation.XmlRootElement;
021
022@XmlRootElement(name = "transaction_error")
023public class TransactionError extends RecurlyObject {
024
025    @XmlElement(name = "error_code")
026    private String errorCode;
027
028    @XmlElement(name = "error_category")
029    private String errorCategory;
030
031    @XmlElement(name = "merchant_message")
032    private String merchantMessage;
033
034    @XmlElement(name = "customer_message")
035    private String customerMessage;
036
037    public String getErrorCode() {
038        return errorCode;
039    }
040
041    public void setErrorCode(final Object errorCode) {
042        this.errorCode = stringOrNull(errorCode);
043    }
044
045    public String getErrorCategory() {
046        return errorCategory;
047    }
048
049    public void setErrorCategory(final Object errorCategory) {
050        this.errorCategory = stringOrNull(errorCategory);
051    }
052
053    public String getMerchantMessage() {
054        return merchantMessage;
055    }
056
057    public void setMerchantMessage(final Object merchantMessage) {
058        this.merchantMessage = stringOrNull(merchantMessage);
059    }
060
061    public String getCustomerMessage() {
062        return customerMessage;
063    }
064
065    public void setCustomerMessage(final Object customerMessage) {
066        this.customerMessage = stringOrNull(customerMessage);
067    }
068
069    @Override
070    public String toString() {
071        final StringBuilder sb = new StringBuilder("TransactionError{");
072        sb.append("errorCode='").append(errorCode).append('\'');
073        sb.append(", errorCategory='").append(errorCategory).append('\'');
074        sb.append(", merchantMessage='").append(merchantMessage).append('\'');
075        sb.append(", customerMessage='").append(customerMessage).append('\'');
076        sb.append('}');
077        return sb.toString();
078    }
079
080    @Override
081    public boolean equals(final Object o) {
082        if (this == o) {
083            return true;
084        }
085        if (o == null || getClass() != o.getClass()) {
086            return false;
087        }
088
089        final TransactionError that = (TransactionError) o;
090
091        if (customerMessage != null ? !customerMessage.equals(that.customerMessage) : that.customerMessage != null) {
092            return false;
093        }
094        if (errorCategory != null ? !errorCategory.equals(that.errorCategory) : that.errorCategory != null) {
095            return false;
096        }
097        if (errorCode != null ? !errorCode.equals(that.errorCode) : that.errorCode != null) {
098            return false;
099        }
100        if (merchantMessage != null ? !merchantMessage.equals(that.merchantMessage) : that.merchantMessage != null) {
101            return false;
102        }
103
104        return true;
105    }
106
107    @Override
108    public int hashCode() {
109        int result = errorCode != null ? errorCode.hashCode() : 0;
110        result = 31 * result + (errorCategory != null ? errorCategory.hashCode() : 0);
111        result = 31 * result + (merchantMessage != null ? merchantMessage.hashCode() : 0);
112        result = 31 * result + (customerMessage != null ? customerMessage.hashCode() : 0);
113        return result;
114    }
115}