View Javadoc

1   /*
2    * Created on Jul 26, 2004
3    */
4   package org.marketchangers.prayer;
5   
6   import java.util.Date;
7   
8   /***
9    * @author Jason Williams
10   * @author <a href="mailto:ypak@wc-group.com">Yong Pak</a>
11   * @author Jianshuo Niu
12   * @hibernate.class table="Contracts"
13   */
14  public class UserContract extends PersistentObject {
15  
16  	/***
17  	 * In the case of prayer requests, contracts are initiated
18  	 * by the requestor, and accepted by the intercessor.
19  	 * When the requestor withdraws the request, the contract
20  	 * is immediately removed from the system, without the
21  	 * intercessor's interaction.
22  	 */
23  
24  	// status constants
25  	public static final String INITIATED = "initiated";
26  	public static final String ACCEPTED = "accepted";
27  	public static final String DECLINED = "declined";
28  	public static final String CANCELLED = "cancelled";
29  
30  	private String status;
31  	private String requestorUserId;
32  	private String requesteeUserId;
33  	private Date date;
34  	private String type;
35  
36  	/***
37  	 * @hibernate.property
38  	 * @return
39  	 */
40  	public Date getDate() {
41  		return date;
42  	}
43  
44  	/***
45  	 * @hibernate.property
46  	 * @return
47  	 */
48  	public String getStatus() {
49  		return status;
50  	}
51  
52  	/***
53  	 * @hibernate.property
54  	 * @deprecated Does not seem to be used anywhere? Undeprecate and add a 
55  	 * comment explaining this field here if I'm wrong. -- MT
56  	 * @return
57  	 */
58  	public String getType() {
59  		return type;
60  	}
61  
62  	/***
63  	 * @param date
64  	 */
65  	public void setDate(Date date) {
66  		this.date = date;
67  	}
68  
69  	/***
70  	 * @param string
71  	 */
72  	public void setStatus(String string) {
73  		status = string;
74  	}
75  
76  	/***
77  	 * @deprecated Does not seem to be used anywhere? Undeprecate and add a 
78  	 * comment explaining this field here if I'm wrong. -- MT
79  	 * @param string
80  	 */
81  	public void setType(String string) {
82  		type = string;
83  	}
84  	/***
85  	 * @hibernate.property
86  	 * @return
87  	 */
88  	public String getRequesteeUserId() {
89  		return requesteeUserId;
90  	}
91  
92  	/***
93  	 * @hibernate.property
94  	 * @return
95  	 */
96  	public String getRequestorUserId() {
97  		return requestorUserId;
98  	}
99  
100 	/***
101 	 * @param string
102 	 */
103 	public void setRequesteeUserId(String string) {
104 		requesteeUserId = string;
105 	}
106 
107 	/***
108 	 * @param string
109 	 */
110 	public void setRequestorUserId(String string) {
111 		requestorUserId = string;
112 	}
113 
114 	public boolean equals(Object o) {
115 		if (this == o) {
116 			return true;
117 		}
118 
119 		if (!(o instanceof UserContract)) {
120 			return false;
121 		}
122 
123 		UserContract other = (UserContract)o;
124 		return equals(this.requesteeUserId, other.requesteeUserId)
125 			&& equals(this.requestorUserId, other.requestorUserId)
126 			&& equals(this.date, other.date);
127 	}
128 
129 	private boolean equals(Object lhs, Object rhs) {
130 		return lhs == null ? rhs == null : lhs.equals(rhs);
131 	}
132 
133 	public int hashCode() {
134 		int result = 11;
135 		result = result * 37 + hashCode(requesteeUserId);
136 		result = result * 37 + hashCode(requestorUserId);
137 		result = result * 37 + hashCode(date);
138 		return result;
139 	}
140 
141 	private int hashCode(Object o) {
142 		return o == null ? 0 : o.hashCode();
143 	}
144 
145 	//Validate() is used to determine if contract has valid parameters 
146 	//For now, that means not null
147 	public boolean validate() {
148 		if ((requesteeUserId == null) || (requestorUserId == null)) {
149 			return false;
150 		}
151 		return true;
152 	}
153 }