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; 021 022import javax.xml.bind.annotation.XmlElement; 023import javax.xml.bind.annotation.XmlRootElement; 024import javax.xml.bind.annotation.XmlTransient; 025 026import com.ning.billing.recurly.model.Account; 027 028import org.joda.time.DateTime; 029 030@XmlRootElement(name = "note") 031public class AccountNote extends RecurlyObject { 032 033 @XmlTransient 034 public static final String ACCOUNT_NOTES_RESOURCE = "/notes"; 035 036 @XmlElement(name = "account") 037 private Account account; 038 039 @XmlElement(name = "message") 040 private String message; 041 042 @XmlElement(name = "created_at") 043 private DateTime createdAt; 044 045 public String getMessage() { 046 return message; 047 } 048 049 public void setMessage(final Object message) { 050 this.message = stringOrNull(message); 051 } 052 053 public DateTime getCreatedAt() { 054 return createdAt; 055 } 056 057 public void setCreatedAt(final Object createdAt) { 058 this.createdAt = dateTimeOrNull(createdAt); 059 } 060 061 @Override 062 public String toString() { 063 final StringBuilder sb = new StringBuilder("AccountNote{"); 064 sb.append("account=").append(account.getAccountCode()); 065 sb.append(", message=").append(message); 066 sb.append(", createdAt=").append(createdAt); 067 sb.append('}'); 068 return sb.toString(); 069 } 070 071 @Override 072 public boolean equals(final Object o) { 073 if (this == o) return true; 074 if (o == null || getClass() != o.getClass()) return false; 075 076 final AccountNote that = (AccountNote) o; 077 078 if (account != null ? !account.equals(that.account) : that.account != null) { 079 return false; 080 } 081 if (message != null ? !message.equals(that.message) : that.message != null) { 082 return false; 083 } 084 if (createdAt != null ? createdAt.compareTo(that.createdAt) != 0 : that.createdAt != null) { 085 return false; 086 } 087 088 return true; 089 } 090 091 @Override 092 public int hashCode() { 093 return Objects.hashCode( 094 account, 095 message, 096 createdAt 097 ); 098 } 099}