View Javadoc
1   /*
2    * Copyright 2007 Kasper B. Graversen
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.supercsv.mock;
17  
18  import java.util.Date;
19  
20  /**
21   * Superclass bean to use when testing bean reading/writing.
22   * 
23   * @author James Bassett
24   */
25  public class CustomerBean extends PersonBean implements Customer {
26  	
27  	private String customerNo;
28  	
29  	private long loyaltyPoints;
30  	
31  	private String mailingAddress;
32  	
33  	/**
34  	 * Default Constructor.
35  	 */
36  	public CustomerBean() {
37  	}
38  	
39  	/**
40  	 * Constructs a CustomerBean.
41  	 * 
42  	 * @param customerNo
43  	 * @param firstName
44  	 * @param lastName
45  	 * @param birthDate
46  	 * @param mailingAddress
47  	 * @param married
48  	 * @param numberOfKids
49  	 * @param favouriteQuote
50  	 * @param email
51  	 * @param loyaltyPoints
52  	 */
53  	public CustomerBean(final String customerNo, final String firstName, final String lastName, final Date birthDate,
54  		final String mailingAddress, final Boolean married, final Integer numberOfKids, final String favouriteQuote,
55  		final String email, final long loyaltyPoints) {
56  		super(firstName, lastName, birthDate, married, numberOfKids, favouriteQuote, email);
57  		this.customerNo = customerNo;
58  		this.loyaltyPoints = loyaltyPoints;
59  		this.mailingAddress = mailingAddress;
60  	}
61  	
62  	/**
63  	 * @return the customerNo
64  	 */
65  	public String getCustomerNo() {
66  		return customerNo;
67  	}
68  	
69  	/**
70  	 * @param customerNo
71  	 *            the customerNo to set
72  	 */
73  	public void setCustomerNo(String customerNo) {
74  		this.customerNo = customerNo;
75  	}
76  	
77  	/**
78  	 * @return the loyaltyPoints
79  	 */
80  	public long getLoyaltyPoints() {
81  		return loyaltyPoints;
82  	}
83  	
84  	/**
85  	 * @param loyaltyPoints
86  	 *            the loyaltyPoints to set
87  	 */
88  	public void setLoyaltyPoints(long loyaltyPoints) {
89  		this.loyaltyPoints = loyaltyPoints;
90  	}
91  	
92  	/**
93  	 * @return the mailingAddress
94  	 */
95  	public String getMailingAddress() {
96  		return mailingAddress;
97  	}
98  	
99  	/**
100 	 * @param mailingAddress
101 	 *            the mailingAddress to set
102 	 */
103 	public void setMailingAddress(String mailingAddress) {
104 		this.mailingAddress = mailingAddress;
105 	}
106 	
107 	@Override
108 	public int hashCode() {
109 		final int prime = 31;
110 		int result = super.hashCode();
111 		result = prime * result + ((customerNo == null) ? 0 : customerNo.hashCode());
112 		result = prime * result + (int) (loyaltyPoints ^ (loyaltyPoints >>> 32));
113 		result = prime * result + ((mailingAddress == null) ? 0 : mailingAddress.hashCode());
114 		return result;
115 	}
116 	
117 	@Override
118 	public boolean equals(final Object obj) {
119 		if( this == obj ) {
120 			return true;
121 		}
122 		if( !super.equals(obj) ) {
123 			return false;
124 		}
125 		if( !(obj instanceof CustomerBean) ) {
126 			return false;
127 		}
128 		CustomerBean other = (CustomerBean) obj;
129 		if( customerNo == null ) {
130 			if( other.customerNo != null ) {
131 				return false;
132 			}
133 		} else if( !customerNo.equals(other.customerNo) ) {
134 			return false;
135 		}
136 		if( loyaltyPoints != other.loyaltyPoints ) {
137 			return false;
138 		}
139 		if( mailingAddress == null ) {
140 			if( other.mailingAddress != null ) {
141 				return false;
142 			}
143 		} else if( !mailingAddress.equals(other.mailingAddress) ) {
144 			return false;
145 		}
146 		return true;
147 	}
148 	
149 	@Override
150 	public String toString() {
151 		return String
152 			.format(
153 				"CustomerBean [customerNo=%s, firstName=%s, lastName=%s, birthDate=%s, mailingAddress=%s, married=%s, numberOfKids=%s, favouriteQuote=%s, email=%s, loyaltyPoints=%s]",
154 				customerNo, getFirstName(), getLastName(), getBirthDate(), mailingAddress, getMarried(),
155 				getNumberOfKids(), getFavouriteQuote(), getEmail(), loyaltyPoints);
156 	}
157 	
158 }