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;
021import org.joda.time.DateTime;
022
023import javax.xml.bind.annotation.XmlElement;
024import javax.xml.bind.annotation.XmlElementWrapper;
025import javax.xml.bind.annotation.XmlRootElement;
026import javax.xml.bind.annotation.XmlTransient;
027
028@XmlRootElement(name = "item")
029public class Item extends RecurlyObject {
030
031  @XmlTransient
032  public static final String ITEMS_RESOURCE = "/items";
033
034  @XmlElement(name = "item_code")
035  private String itemCode;
036
037  @XmlElement(name = "name")
038  private String name;
039
040  @XmlElement(name = "description")
041  private String description;
042
043  @XmlElement(name = "external_sku")
044  private String externalSku;
045
046  @XmlElement(name = "accounting_code")
047  private String accountingCode;
048
049  @XmlElement(name = "revenue_schedule_type")
050  private String revenueScheduleType;
051
052  @XmlElement(name = "state")
053  private String state;
054
055  @XmlElementWrapper(name = "custom_fields")
056  @XmlElement(name = "custom_field")
057  private CustomFields customFields;
058
059  @XmlElement(name = "created_at")
060  private DateTime createdAt;
061
062  @XmlElement(name = "updated_at")
063  private DateTime updatedAt;
064
065  public String getItemCode() {
066    return itemCode;
067  }
068
069  public void setItemCode(final Object itemCode) {
070    this.itemCode = stringOrNull(itemCode);
071  }
072
073  public String getName() {
074    return name;
075  }
076
077  public void setName(final Object name) {
078    this.name = stringOrNull(name);
079  }
080
081  public String getDescription() {
082    return description;
083  }
084
085  public void setDescription(final Object description) {
086      this.description = stringOrNull(description);
087  }
088
089  public String getExternalSku() {
090    return externalSku;
091  }
092
093  public void setExternalSku(final Object externalSku) {
094    this.externalSku = stringOrNull(externalSku);
095  }
096
097  public String getRevenueScheduleType() {
098    return revenueScheduleType;
099  }
100
101  public void setRevenueScheduleType(final Object revenueScheduleType) {
102    this.revenueScheduleType = stringOrNull(revenueScheduleType);
103  }
104
105  public String getAccountingCode() {
106    return accountingCode;
107  }
108
109  public void setAccountingCode(final Object accountingCode) {
110    this.accountingCode = stringOrNull(accountingCode);
111  }
112
113  public String getState() {
114    return state;
115  }
116
117  public void setState(final Object state) {
118    this.state = stringOrNull(state);
119  }
120
121  public CustomFields getCustomFields() {
122    return customFields;
123  }
124
125  public void setCustomFields(final CustomFields customFields) {
126      this.customFields = customFields;
127  }
128
129  public DateTime getCreatedAt() {
130    return createdAt;
131  }
132
133  public void setCreatedAt(final Object createdAt) {
134      this.createdAt = dateTimeOrNull(createdAt);
135  }
136
137  public DateTime getUpdatedAt() {
138      return updatedAt;
139  }
140
141  public void setUpdatedAt(final Object updatedAt) {
142      this.updatedAt = dateTimeOrNull(updatedAt);
143  }
144
145  @Override
146  public String toString() {
147    final StringBuilder sb = new StringBuilder();
148    sb.append("Item");
149    sb.append(", itemCode='").append(itemCode).append('\'');
150    sb.append(", name='").append(name).append('\'');
151    sb.append(", description='").append(description).append('\'');
152    sb.append(", externalSku='").append(externalSku).append('\'');
153    sb.append(", accountingCode='").append(accountingCode).append('\'');
154    sb.append(", revenueScheduleType='").append(revenueScheduleType).append('\'');
155    sb.append(", state='").append(state).append('\'');
156    sb.append(", customFields=").append(customFields);
157    sb.append(", createdAt=").append(createdAt);
158    sb.append(", updatedAt=").append(updatedAt);
159    sb.append('}');
160    return sb.toString();
161  }
162
163  @Override
164  public boolean equals(final Object o) {
165    if (this == o) return true;
166    if (o == null || getClass() != o.getClass()) return false;
167
168    final Item item = (Item) o;
169
170    if (accountingCode != null ? !accountingCode.equals(item.accountingCode) : item.accountingCode != null) {
171      return false;
172    }
173
174    if (createdAt != null ? createdAt.compareTo(item.createdAt) != 0: item.createdAt != null) {
175      return false;
176    }
177
178    if (customFields != null ? !customFields.equals(item.customFields) : item.customFields != null) {
179      return false;
180    }
181
182    if (description != null ? !description.equals(item.description) : item.description != null) {
183      return false;
184    }
185
186    if (externalSku != null ? !externalSku.equals(item.externalSku) : item.externalSku != null) {
187      return false;
188    }
189
190    if (itemCode != null ? !itemCode.equals(item.itemCode) : item.itemCode != null) {
191      return false;
192    }
193
194    if (name != null ? !name.equals(item.name) : item.name != null) {
195      return false;
196    }
197
198    if (revenueScheduleType != null ? !revenueScheduleType.equals(item.revenueScheduleType) : item.revenueScheduleType != null) {
199      return false;
200    }
201
202    if (state != null ? !state.equals(item.state) : item.state != null) {
203      return false;
204    }
205
206    if (updatedAt != null ? updatedAt.compareTo(item.updatedAt) != 0: item.updatedAt != null) {
207      return false;
208    }
209    return true;
210  }
211
212  @Override
213  public int hashCode() {
214    return Objects.hashCode(
215      accountingCode,
216      customFields,
217      createdAt,
218      description,
219      externalSku,
220      itemCode,
221      name,
222      revenueScheduleType,
223      state,
224      updatedAt
225    );
226  }
227}