View Javadoc

1   /**
2    * Copyright 2004-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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.kuali.hr.time.timeblock;
17  
18  import java.math.BigDecimal;
19  
20  import org.apache.commons.lang.builder.EqualsBuilder;
21  import org.apache.commons.lang.builder.HashCodeBuilder;
22  import org.kuali.hr.time.util.TkConstants;
23  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
24  
25  public class TimeHourDetail extends PersistableBusinessObjectBase{
26  
27  	/**
28  	 *
29  	 */
30  	private static final long serialVersionUID = 1L;
31  	private String tkTimeHourDetailId;
32  	private String tkTimeBlockId;
33  	private String earnCode;
34  	private BigDecimal hours = TkConstants.BIG_DECIMAL_SCALED_ZERO;
35  	private BigDecimal amount = TkConstants.BIG_DECIMAL_SCALED_ZERO;
36  
37      public TimeHourDetail() {
38      }
39  
40      protected TimeHourDetail(TimeHourDetail t) {
41          // All of the following are Immutable, be aware if new fields
42          // are added.
43          this.tkTimeHourDetailId = t.tkTimeHourDetailId;
44          this.tkTimeBlockId = t.tkTimeBlockId;
45          this.earnCode = t.earnCode;
46          this.hours = t.hours;
47          this.amount = t.amount;
48      }
49  
50      public TimeHourDetail copy() {
51          return new TimeHourDetail(this);
52      }
53  
54  	public String getEarnCode() {
55  		return earnCode;
56  	}
57  
58  	public void setEarnCode(String earnCode) {
59  		this.earnCode = earnCode;
60  	}
61  
62  	public BigDecimal getHours() {
63  		return hours;
64  	}
65  
66  	public void setHours(BigDecimal hours) {
67  		if(hours != null){
68  			this.hours = hours.setScale(TkConstants.BIG_DECIMAL_SCALE, TkConstants.BIG_DECIMAL_SCALE_ROUNDING);
69  		} else {
70  			this.hours = hours;
71  		}
72  	}
73  
74  	public BigDecimal getAmount() {
75  		return amount;
76  	}
77  
78  	public void setAmount(BigDecimal amount) {
79  		if(amount != null){
80  			this.amount = amount.setScale(TkConstants.BIG_DECIMAL_SCALE, TkConstants.BIG_DECIMAL_SCALE_ROUNDING);
81  		} else {
82  			this.amount = amount;
83  		}
84  	}
85  
86  	public String getTkTimeBlockId() {
87  		return tkTimeBlockId;
88  	}
89  
90  	public void setTkTimeBlockId(String tkTimeBlockId) {
91  		this.tkTimeBlockId = tkTimeBlockId;
92  	}
93  	public void setTkTimeHourDetailId(String tkTimeHourDetailId) {
94  		this.tkTimeHourDetailId = tkTimeHourDetailId;
95  	}
96  
97  	public String getTkTimeHourDetailId() {
98  		return tkTimeHourDetailId;
99  	}
100 	
101 	@Override
102 	public boolean equals(Object obj) {
103 		if (obj == null) { 
104 			return false;
105 		}
106 		if (obj == this) { 
107 			return true;
108 		}
109 		if (obj.getClass() != getClass()) {
110 			return false;
111 		}
112 		TimeHourDetail timeHourDetail = (TimeHourDetail) obj;
113 		return new EqualsBuilder()
114 			.append(earnCode, timeHourDetail.earnCode)
115 			.append(amount, timeHourDetail.amount)
116 			.append(hours, timeHourDetail.hours)
117 			.isEquals();
118 	}
119 
120 	@Override
121 	public int hashCode() {
122 		return new HashCodeBuilder(17, 31)
123 			.append(earnCode)
124 			.append(amount)
125 			.append(hours)
126 			.toHashCode();
127 	}
128 
129 }