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 022import org.joda.time.DateTime; 023 024@XmlRootElement(name = "adjustment") 025public class Adjustment extends RecurlyObject { 026 027 @XmlElement(name = "account") 028 private Account account; 029 030 @XmlElement(name = "uuid") 031 private String uuid; 032 033 @XmlElement(name = "description") 034 private String description; 035 036 @XmlElement(name = "accounting_code") 037 private String accountingCode; 038 039 @XmlElement(name = "origin") 040 private String origin; 041 042 @XmlElement(name = "unit_amount_in_cents") 043 private Integer unitAmountInCents; 044 045 @XmlElement(name = "quantity") 046 private Integer quantity; 047 048 @XmlElement(name = "discount_in_cents") 049 private Integer discountInCents; 050 051 @XmlElement(name = "tax_in_cents") 052 private Integer taxInCents; 053 054 @XmlElement(name = "total_in_cents") 055 private Integer totalInCents; 056 057 @XmlElement(name = "currency") 058 private String currency; 059 060 @XmlElement(name = "taxable") 061 private Boolean taxable; 062 063 @XmlElement(name = "start_date") 064 private DateTime startDate; 065 066 @XmlElement(name = "end_date") 067 private DateTime endDate; 068 069 @XmlElement(name = "created_at") 070 private DateTime createdAt; 071 072 public Account getAccount() { 073 if (account != null && account.getCreatedAt() == null) { 074 account = fetch(account, Account.class); 075 } 076 return account; 077 } 078 079 public void setAccount(final Account account) { 080 this.account = account; 081 } 082 083 public String getUuid() { 084 return uuid; 085 } 086 087 public void setUuid(final Object uuid) { 088 this.uuid = stringOrNull(uuid); 089 } 090 091 public String getDescription() { 092 return description; 093 } 094 095 public void setDescription(final Object description) { 096 this.description = stringOrNull(description); 097 } 098 099 public String getAccountingCode() { 100 return accountingCode; 101 } 102 103 public void setAccountingCode(final Object accountingCode) { 104 this.accountingCode = stringOrNull(accountingCode); 105 } 106 107 public String getOrigin() { 108 return origin; 109 } 110 111 public void setOrigin(final Object origin) { 112 this.origin = stringOrNull(origin); 113 } 114 115 public Integer getUnitAmountInCents() { 116 return unitAmountInCents; 117 } 118 119 public void setUnitAmountInCents(final Object unitAmountInCents) { 120 this.unitAmountInCents = integerOrNull(unitAmountInCents); 121 } 122 123 public Integer getQuantity() { 124 return quantity; 125 } 126 127 public void setQuantity(final Object quantity) { 128 this.quantity = integerOrNull(quantity); 129 } 130 131 public Integer getDiscountInCents() { 132 return discountInCents; 133 } 134 135 public void setDiscountInCents(final Object discountInCents) { 136 this.discountInCents = integerOrNull(discountInCents); 137 } 138 139 public Integer getTaxInCents() { 140 return taxInCents; 141 } 142 143 public void setTaxInCents(final Object taxInCents) { 144 this.taxInCents = integerOrNull(taxInCents); 145 } 146 147 public Integer getTotalInCents() { 148 return totalInCents; 149 } 150 151 public void setTotalInCents(final Object totalInCents) { 152 this.totalInCents = integerOrNull(totalInCents); 153 } 154 155 public String getCurrency() { 156 return currency; 157 } 158 159 public void setCurrency(final Object currency) { 160 this.currency = stringOrNull(currency); 161 } 162 163 public Boolean getTaxable() { 164 return taxable; 165 } 166 167 public void setTaxable(final Object taxable) { 168 this.taxable = booleanOrNull(taxable); 169 } 170 171 public DateTime getStartDate() { 172 return startDate; 173 } 174 175 public void setStartDate(final Object startDate) { 176 this.startDate = dateTimeOrNull(startDate); 177 } 178 179 public DateTime getEndDate() { 180 return endDate; 181 } 182 183 public void setEndDate(final Object endDate) { 184 this.endDate = dateTimeOrNull(endDate); 185 } 186 187 public DateTime getCreatedAt() { 188 return createdAt; 189 } 190 191 public void setCreatedAt(final Object createdAt) { 192 this.createdAt = dateTimeOrNull(createdAt); 193 } 194 195 @Override 196 public String toString() { 197 final StringBuilder sb = new StringBuilder(); 198 sb.append("Adjustment"); 199 sb.append("{account=").append(account); 200 sb.append(", uuid='").append(uuid).append('\''); 201 sb.append(", description='").append(description).append('\''); 202 sb.append(", accountingCode='").append(accountingCode).append('\''); 203 sb.append(", origin='").append(origin).append('\''); 204 sb.append(", unitAmountInCents=").append(unitAmountInCents); 205 sb.append(", quantity=").append(quantity); 206 sb.append(", discountInCents=").append(discountInCents); 207 sb.append(", taxInCents=").append(taxInCents); 208 sb.append(", totalInCents=").append(totalInCents); 209 sb.append(", currency='").append(currency).append('\''); 210 sb.append(", taxable=").append(taxable); 211 sb.append(", startDate=").append(startDate); 212 sb.append(", endDate=").append(endDate); 213 sb.append(", createdAt=").append(createdAt); 214 sb.append('}'); 215 return sb.toString(); 216 } 217 218 @Override 219 public boolean equals(final Object o) { 220 if (this == o) { 221 return true; 222 } 223 if (o == null || getClass() != o.getClass()) { 224 return false; 225 } 226 227 final Adjustment that = (Adjustment) o; 228 229 if (account != null ? !account.equals(that.account) : that.account != null) { 230 return false; 231 } 232 if (accountingCode != null ? !accountingCode.equals(that.accountingCode) : that.accountingCode != null) { 233 return false; 234 } 235 if (createdAt != null ? !createdAt.equals(that.createdAt) : that.createdAt != null) { 236 return false; 237 } 238 if (currency != null ? !currency.equals(that.currency) : that.currency != null) { 239 return false; 240 } 241 if (description != null ? !description.equals(that.description) : that.description != null) { 242 return false; 243 } 244 if (discountInCents != null ? !discountInCents.equals(that.discountInCents) : that.discountInCents != null) { 245 return false; 246 } 247 if (endDate != null ? !endDate.equals(that.endDate) : that.endDate != null) { 248 return false; 249 } 250 if (origin != null ? !origin.equals(that.origin) : that.origin != null) { 251 return false; 252 } 253 if (quantity != null ? !quantity.equals(that.quantity) : that.quantity != null) { 254 return false; 255 } 256 if (startDate != null ? !startDate.equals(that.startDate) : that.startDate != null) { 257 return false; 258 } 259 if (taxInCents != null ? !taxInCents.equals(that.taxInCents) : that.taxInCents != null) { 260 return false; 261 } 262 if (taxable != null ? !taxable.equals(that.taxable) : that.taxable != null) { 263 return false; 264 } 265 if (totalInCents != null ? !totalInCents.equals(that.totalInCents) : that.totalInCents != null) { 266 return false; 267 } 268 if (unitAmountInCents != null ? !unitAmountInCents.equals(that.unitAmountInCents) : that.unitAmountInCents != null) { 269 return false; 270 } 271 if (uuid != null ? !uuid.equals(that.uuid) : that.uuid != null) { 272 return false; 273 } 274 275 return true; 276 } 277 278 @Override 279 public int hashCode() { 280 int result = account != null ? account.hashCode() : 0; 281 result = 31 * result + (uuid != null ? uuid.hashCode() : 0); 282 result = 31 * result + (description != null ? description.hashCode() : 0); 283 result = 31 * result + (accountingCode != null ? accountingCode.hashCode() : 0); 284 result = 31 * result + (origin != null ? origin.hashCode() : 0); 285 result = 31 * result + (unitAmountInCents != null ? unitAmountInCents.hashCode() : 0); 286 result = 31 * result + (quantity != null ? quantity.hashCode() : 0); 287 result = 31 * result + (discountInCents != null ? discountInCents.hashCode() : 0); 288 result = 31 * result + (taxInCents != null ? taxInCents.hashCode() : 0); 289 result = 31 * result + (totalInCents != null ? totalInCents.hashCode() : 0); 290 result = 31 * result + (currency != null ? currency.hashCode() : 0); 291 result = 31 * result + (taxable != null ? taxable.hashCode() : 0); 292 result = 31 * result + (startDate != null ? startDate.hashCode() : 0); 293 result = 31 * result + (endDate != null ? endDate.hashCode() : 0); 294 result = 31 * result + (createdAt != null ? createdAt.hashCode() : 0); 295 return result; 296 } 297}