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 */ 017package com.ning.billing.recurly.model; 018 019import com.google.common.base.Objects; 020 021import java.math.BigDecimal; 022 023import javax.xml.bind.annotation.XmlElement; 024import javax.xml.bind.annotation.XmlRootElement; 025 026@XmlRootElement(name = "tax_detail") 027public class TaxDetail extends RecurlyObject{ 028 029 @XmlElement(name = "name") 030 protected String name; 031 032 @XmlElement(name = "type") 033 private String type; 034 035 @XmlElement(name = "tax_rate") 036 private BigDecimal taxRate; 037 038 @XmlElement(name = "tax_in_cents") 039 private Integer taxInCents; 040 041 public String getName() { 042 return name; 043 } 044 045 public void setName(final Object name) { 046 this.name = stringOrNull(name); 047 } 048 049 public String getType() { 050 return type; 051 } 052 053 public void setType(final Object type) { 054 this.type = stringOrNull(type); 055 } 056 057 public BigDecimal getTaxRate() { 058 return taxRate; 059 } 060 061 public void setTaxRate(final Object taxRate) { 062 this.taxRate = bigDecimalOrNull(taxRate); 063 } 064 065 public Integer getTaxInCents() { 066 return taxInCents; 067 } 068 069 public void setTaxInCents(final Object taxInCents) { 070 this.taxInCents = integerOrNull(taxInCents); 071 } 072 073 @Override 074 public String toString() { 075 final StringBuilder sb = new StringBuilder(); 076 sb.append("TaxDetail{"); 077 sb.append("name='").append(name).append('\''); 078 sb.append(", type='").append(type).append('\''); 079 sb.append(", taxRate=").append(taxRate); 080 sb.append(", taxInCents=").append(taxInCents); 081 sb.append('}'); 082 return sb.toString(); 083 } 084 085 @Override 086 public boolean equals(Object o) { 087 if (this == o) return true; 088 if (o == null || getClass() != o.getClass()) return false; 089 090 final TaxDetail that = (TaxDetail) o; 091 092 if (name != null ? !name.equals(that.name) : that.name != null) { 093 return false; 094 } 095 if (type != null ? !type.equals(that.type) : that.type != null) { 096 return false; 097 } 098 if (taxRate != null ? !taxRate.equals(that.taxRate) : that.taxRate != null) { 099 return false; 100 } 101 if (taxInCents != null ? !taxInCents.equals(that.taxInCents) : that.taxInCents != null) { 102 return false; 103 } 104 return true; 105 } 106 107 @Override 108 public int hashCode() { 109 return Objects.hashCode( 110 name, 111 type, 112 taxRate, 113 taxInCents 114 ); 115 } 116 117}