001/*
002 * Copyright 2018 The Billing Project, LLC
003 *
004 * The Billing Project 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 com.fasterxml.jackson.databind.annotation.JsonSerialize;
020import com.google.common.base.Objects;
021
022import javax.xml.bind.annotation.XmlRootElement;
023
024@JsonSerialize(using = PlanCodeSerializer.class)
025@XmlRootElement(name = "plan_code")
026public class PlanCode extends RecurlyObject {
027
028    private String name;
029
030    public PlanCode() { /* Required for Jackson */ }
031
032    public PlanCode(final String name) {
033        this.name = name;
034    }
035
036    public String getName() {
037        return name;
038    }
039
040    public void setName(final Object name) {
041        this.name = stringOrNull(name);
042    }
043
044    @Override
045    public String toString() {
046        final StringBuilder sb = new StringBuilder("PlanCode{");
047        sb.append("name=").append(name);
048        sb.append('}');
049        return sb.toString();
050    }
051
052    @Override
053    public boolean equals(final Object o) {
054        if (this == o) return true;
055        if (o == null || getClass() != o.getClass()) return false;
056
057        final PlanCode field = (PlanCode) o;
058
059        if (name != null ? !name.equals(field.name) : field.name != null) {
060            return false;
061        }
062
063        return true;
064    }
065
066    @Override
067    public int hashCode() {
068        return Objects.hashCode(name);
069    }
070}