View Javadoc
1   /**
2    * Copyright 2005-2014 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.rice.core.api.criteria;
17  
18  import org.apache.commons.lang.builder.EqualsBuilder;
19  import org.apache.commons.lang.builder.HashCodeBuilder;
20  import org.apache.commons.lang.builder.ToStringBuilder;
21  
22  import javax.xml.bind.annotation.XmlAccessType;
23  import javax.xml.bind.annotation.XmlAccessorType;
24  import javax.xml.bind.annotation.XmlRootElement;
25  import javax.xml.bind.annotation.XmlType;
26  import javax.xml.bind.annotation.XmlValue;
27  
28  /**
29   * A CriteriaValue which stores date and time information in the form of a
30   * {@link String} value.
31   * 
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   *
34   */
35  @XmlRootElement(name = CriteriaBooleanValue.Constants.ROOT_ELEMENT_NAME)
36  @XmlAccessorType(XmlAccessType.NONE)
37  @XmlType(name = CriteriaBooleanValue.Constants.TYPE_NAME)
38  public final class CriteriaBooleanValue implements CriteriaValue<Boolean> {
39  
40      @XmlValue
41      private final Boolean value;
42  
43      CriteriaBooleanValue() {
44          this.value = null;
45      }
46  
47      CriteriaBooleanValue(Boolean value) {
48      	if (value == null) {
49      		throw new IllegalArgumentException("Value cannot be null.");
50      	}
51      	this.value = value;
52      }
53      
54      @Override
55      public Boolean getValue() {
56          return value;
57      }
58      
59      @Override
60      public int hashCode() {
61          return HashCodeBuilder.reflectionHashCode(this);
62      }
63  
64      @Override
65      public boolean equals(Object obj) {
66          return EqualsBuilder.reflectionEquals(obj, this);
67      }
68  
69      @Override
70      public String toString() {
71          return ToStringBuilder.reflectionToString(this);
72      }
73      
74      /**
75       * Defines some internal constants used on this class.
76       */
77      static class Constants {
78          final static String ROOT_ELEMENT_NAME = "booleanValue";
79          final static String TYPE_NAME = "CriteriaBooleanValueType";
80      }
81      
82  }