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; 022 023import com.google.common.base.Objects; 024 025@XmlRootElement(name = "shipping_fee") 026public class ShippingFee extends RecurlyObject { 027 028 @XmlElement(name = "shipping_method_code") 029 private String shippingMethodCode; 030 031 @XmlElement(name = "shipping_amount_in_cents") 032 private Integer shippingAmountInCents; 033 034 @XmlElement(name = "shipping_address_id") 035 private Long shippingAddressId; 036 037 @XmlElement(name = "shipping_address") 038 private ShippingAddress shippingAddress; 039 040 public String getShippingMethodCode() { 041 return shippingMethodCode; 042 } 043 044 public void setShippingMethodCode(final Object shippingMethodCode) { 045 this.shippingMethodCode = stringOrNull(shippingMethodCode); 046 } 047 048 public Integer getShippingAmountInCents() { 049 return shippingAmountInCents; 050 } 051 052 public void setShippingAmountInCents(final Object shippingAmountInCents) { 053 this.shippingAmountInCents = integerOrNull(shippingAmountInCents); 054 } 055 056 public Long getShippingAddressId() { 057 return shippingAddressId; 058 } 059 060 public void setShippingAddressId(final Object shippingAddressId) { 061 this.shippingAddressId = longOrNull(shippingAddressId); 062 } 063 064 public ShippingAddress getShippingAddress() { 065 return shippingAddress; 066 } 067 068 public void setShippingAddress(final ShippingAddress shippingAddress) { 069 this.shippingAddress = shippingAddress; 070 } 071 072 @Override 073 public String toString() { 074 final StringBuilder sb = new StringBuilder(); 075 sb.append("ShippingFee"); 076 sb.append("{shippingMethodCode=").append(shippingMethodCode); 077 sb.append(", shippingAmountInCents=").append(shippingAmountInCents); 078 sb.append(", shippingAddressId=").append(shippingAddressId); 079 sb.append(", shippingAddress=").append(shippingAddress); 080 sb.append('}'); 081 return sb.toString(); 082 } 083 084 @Override 085 public boolean equals(final Object o) { 086 if (this == o) return true; 087 if (o == null || getClass() != o.getClass()) return false; 088 089 final ShippingFee that = (ShippingFee) o; 090 091 if (shippingMethodCode != null ? !shippingMethodCode.equals(that.shippingMethodCode) : that.shippingMethodCode != null) { 092 return false; 093 } 094 if (shippingAmountInCents != null ? !shippingAmountInCents.equals(that.shippingAmountInCents) : that.shippingAmountInCents != null) { 095 return false; 096 } 097 if (shippingAddressId != null ? !shippingAddressId.equals(that.shippingAddressId) : that.shippingAddressId != null) { 098 return false; 099 } 100 if (shippingAddress != null ? !shippingAddress.equals(that.shippingAddress) : that.shippingAddress != null) { 101 return false; 102 } 103 104 return true; 105 } 106 107 @Override 108 public int hashCode() { 109 return Objects.hashCode( 110 shippingMethodCode, 111 shippingAmountInCents, 112 shippingAddressId, 113 shippingAddress 114 ); 115 } 116}