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 com.google.common.base.Objects;
023
024@XmlRootElement(name = "error")
025public class RecurlyError extends RecurlyObject {
026
027    @XmlElement(name = "field")
028    private String field;
029
030    @XmlElement(name = "symbol")
031    private String symbol;
032
033    @XmlElement(name = "message")
034    private String message;
035
036    public String getField() {
037        return field;
038    }
039
040    public void setField(final String field) {
041        this.field = field;
042    }
043
044    public String getSymbol() {
045        return symbol;
046    }
047
048    public void setSymbol(final String symbol) {
049        this.symbol = symbol;
050    }
051
052    public String getMessage() {
053        return message;
054    }
055
056    public void setMessage(final String message) {
057        this.message = message;
058    }
059
060    @Override
061    public String toString() {
062        final StringBuilder sb = new StringBuilder("RecurlyError{");
063        sb.append("field='").append(field).append('\'');
064        sb.append(", symbol='").append(symbol).append('\'');
065        sb.append(", message='").append(message).append('\'');
066        sb.append('}');
067        return sb.toString();
068    }
069
070    @Override
071    public boolean equals(final Object o) {
072        if (this == o) return true;
073        if (o == null || getClass() != o.getClass()) return false;
074
075        final RecurlyError that = (RecurlyError) o;
076
077        if (field != null ? !field.equals(that.field) : that.field != null) {
078            return false;
079        }
080        if (message != null ? !message.equals(that.message) : that.message != null) {
081            return false;
082        }
083        if (symbol != null ? !symbol.equals(that.symbol) : that.symbol != null) {
084            return false;
085        }
086
087        return true;
088    }
089
090    @Override
091    public int hashCode() {
092        return Objects.hashCode(
093                field,
094                symbol,
095                message
096        );
097    }
098}