View Javadoc

1   /**
2    * Copyright 2005-2012 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 javax.xml.bind.annotation.XmlAccessType;
19  import javax.xml.bind.annotation.XmlAccessorType;
20  import javax.xml.bind.annotation.XmlRootElement;
21  import javax.xml.bind.annotation.XmlType;
22  import javax.xml.bind.annotation.XmlValue;
23  
24  import org.apache.commons.lang.builder.EqualsBuilder;
25  import org.apache.commons.lang.builder.HashCodeBuilder;
26  import org.apache.commons.lang.builder.ToStringBuilder;
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 = CriteriaStringValue.Constants.ROOT_ELEMENT_NAME)
36  @XmlAccessorType(XmlAccessType.NONE)
37  @XmlType(name = CriteriaStringValue.Constants.TYPE_NAME)
38  public final class CriteriaStringValue implements CriteriaValue<String> {
39  
40      @XmlValue
41      private final String value;
42      
43      CriteriaStringValue() {
44          this.value = null;
45      }
46          
47      CriteriaStringValue(CharSequence value) {
48      	if (value == null) {
49      		throw new IllegalArgumentException("Value cannot be null.");
50      	}
51      	this.value = value.toString();
52      }
53      
54      @Override
55      public String 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 = "stringValue";
79          final static String TYPE_NAME = "CriteriaStringValueType";
80      }
81      
82  }