001    /**
002     * Copyright 2004-2013 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.hr.time.timeblock;
017    
018    import java.math.BigDecimal;
019    
020    import org.apache.commons.lang.builder.EqualsBuilder;
021    import org.apache.commons.lang.builder.HashCodeBuilder;
022    import org.kuali.hr.time.util.TkConstants;
023    import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
024    
025    public class TimeHourDetail extends PersistableBusinessObjectBase{
026    
027            /**
028             *
029             */
030            private static final long serialVersionUID = 1L;
031            private String tkTimeHourDetailId;
032            private String tkTimeBlockId;
033            private String earnCode;
034            private BigDecimal hours = TkConstants.BIG_DECIMAL_SCALED_ZERO;
035            private BigDecimal amount = TkConstants.BIG_DECIMAL_SCALED_ZERO;
036    
037        public TimeHourDetail() {
038        }
039    
040        protected TimeHourDetail(TimeHourDetail t) {
041            // All of the following are Immutable, be aware if new fields
042            // are added.
043            this.tkTimeHourDetailId = t.tkTimeHourDetailId;
044            this.tkTimeBlockId = t.tkTimeBlockId;
045            this.earnCode = t.earnCode;
046            this.hours = t.hours;
047            this.amount = t.amount;
048        }
049    
050        public TimeHourDetail copy() {
051            return new TimeHourDetail(this);
052        }
053    
054            public String getEarnCode() {
055                    return earnCode;
056            }
057    
058            public void setEarnCode(String earnCode) {
059                    this.earnCode = earnCode;
060            }
061    
062            public BigDecimal getHours() {
063                    return hours;
064            }
065    
066            public void setHours(BigDecimal hours) {
067                    if(hours != null){
068                            this.hours = hours.setScale(TkConstants.BIG_DECIMAL_SCALE, TkConstants.BIG_DECIMAL_SCALE_ROUNDING);
069                    } else {
070                            this.hours = hours;
071                    }
072            }
073    
074            public BigDecimal getAmount() {
075                    return amount;
076            }
077    
078            public void setAmount(BigDecimal amount) {
079                    if(amount != null){
080                            this.amount = amount.setScale(TkConstants.BIG_DECIMAL_SCALE, TkConstants.BIG_DECIMAL_SCALE_ROUNDING);
081                    } else {
082                            this.amount = amount;
083                    }
084            }
085    
086            public String getTkTimeBlockId() {
087                    return tkTimeBlockId;
088            }
089    
090            public void setTkTimeBlockId(String tkTimeBlockId) {
091                    this.tkTimeBlockId = tkTimeBlockId;
092            }
093            public void setTkTimeHourDetailId(String tkTimeHourDetailId) {
094                    this.tkTimeHourDetailId = tkTimeHourDetailId;
095            }
096    
097            public String getTkTimeHourDetailId() {
098                    return tkTimeHourDetailId;
099            }
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    }