Coverage Report - org.kuali.rice.core.api.criteria.CriteriaDecimalValue
 
Classes in this File Line Coverage Branch Coverage Complexity
CriteriaDecimalValue
69%
16/23
50%
1/2
1.222
CriteriaDecimalValue$Constants
0%
0/1
N/A
1.222
 
 1  
 /*
 2  
  * Copyright 2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 1.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/ecl1.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.rice.core.api.criteria;
 17  
 
 18  
 import java.math.BigDecimal;
 19  
 
 20  
 import javax.xml.bind.annotation.XmlAccessType;
 21  
 import javax.xml.bind.annotation.XmlAccessorType;
 22  
 import javax.xml.bind.annotation.XmlRootElement;
 23  
 import javax.xml.bind.annotation.XmlType;
 24  
 import javax.xml.bind.annotation.XmlValue;
 25  
 
 26  
 import org.apache.commons.lang.builder.EqualsBuilder;
 27  
 import org.apache.commons.lang.builder.HashCodeBuilder;
 28  
 import org.apache.commons.lang.builder.ToStringBuilder;
 29  
 
 30  
 /**
 31  
  * A CriteriaValue which stores date and time information in the form of a
 32  
  * {@link BigDecimal} value.
 33  
  * 
 34  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 35  
  *
 36  
  */
 37  3
 @XmlRootElement(name = CriteriaDecimalValue.Constants.ROOT_ELEMENT_NAME)
 38  
 @XmlAccessorType(XmlAccessType.NONE)
 39  
 @XmlType(name = CriteriaDecimalValue.Constants.TYPE_NAME)
 40  
 public final class CriteriaDecimalValue implements CriteriaValue<BigDecimal> {
 41  
 
 42  
     @XmlValue
 43  
     private final BigDecimal value;
 44  
     
 45  26
     CriteriaDecimalValue() {
 46  26
         this.value = null;
 47  26
     }
 48  
     
 49  17
     CriteriaDecimalValue(BigDecimal value) {
 50  17
             validateValue(value);
 51  17
         this.value = value;
 52  17
     }
 53  
     
 54  0
     CriteriaDecimalValue(Float value) {
 55  0
             validateValue(value);
 56  0
             this.value = BigDecimal.valueOf(value.doubleValue());
 57  0
     }
 58  
         
 59  29
     CriteriaDecimalValue(Double value) {
 60  29
             validateValue(value);
 61  29
             this.value = BigDecimal.valueOf(value.doubleValue());
 62  29
     }
 63  
     
 64  
     private static void validateValue(Object value) {
 65  46
             if (value == null) {
 66  0
                     throw new IllegalArgumentException("Value cannot be null.");
 67  
             }
 68  46
     }
 69  
     
 70  
     @Override
 71  
     public BigDecimal getValue() {
 72  3
         return value;
 73  
     }
 74  
     
 75  
     @Override
 76  
     public int hashCode() {
 77  0
         return HashCodeBuilder.reflectionHashCode(this);
 78  
     }
 79  
 
 80  
     @Override
 81  
     public boolean equals(Object obj) {
 82  26
         return EqualsBuilder.reflectionEquals(obj, this);
 83  
     }
 84  
 
 85  
     @Override
 86  
     public String toString() {
 87  0
         return ToStringBuilder.reflectionToString(this);
 88  
     }
 89  
     
 90  
     /**
 91  
      * Defines some internal constants used on this class.
 92  
      */
 93  0
     static class Constants {
 94  
         final static String ROOT_ELEMENT_NAME = "decimalValue";
 95  
         final static String TYPE_NAME = "CriteriaDecimalValueType";
 96  
     }
 97  
     
 98  
 }