View Javadoc
1   /**
2    * Copyright 2005-2015 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.kuali.rice.core.api.CoreConstants;
19  import org.w3c.dom.Element;
20  
21  import javax.xml.bind.annotation.XmlAccessType;
22  import javax.xml.bind.annotation.XmlAccessorType;
23  import javax.xml.bind.annotation.XmlAnyElement;
24  import javax.xml.bind.annotation.XmlAttribute;
25  import javax.xml.bind.annotation.XmlElement;
26  import javax.xml.bind.annotation.XmlElements;
27  import javax.xml.bind.annotation.XmlRootElement;
28  import javax.xml.bind.annotation.XmlType;
29  
30  import java.util.Collection;
31  
32  /**
33   * An immutable predicate which represents a "greater than or equal to" statement which is
34   * evaluated the {@link CriteriaValue} of this predicate.
35   *
36   * @see PredicateFactory for a convenient way to construct this class.
37   * 
38   * @author Kuali Rice Team (rice.collab@kuali.org)
39   * 
40   */
41  @XmlRootElement(name = GreaterThanOrEqualPredicate.Constants.ROOT_ELEMENT_NAME)
42  @XmlAccessorType(XmlAccessType.NONE)
43  @XmlType(name = GreaterThanOrEqualPredicate.Constants.TYPE_NAME, propOrder = {
44      CriteriaSupportUtils.PropertyConstants.VALUE,
45      CoreConstants.CommonElements.FUTURE_ELEMENTS
46  })
47  public final class GreaterThanOrEqualPredicate extends AbstractPredicate implements SingleValuedPredicate {
48  	    
49  	private static final long serialVersionUID = 2576163857285296720L;
50  	
51  	@XmlAttribute(name = CriteriaSupportUtils.PropertyConstants.PROPERTY_PATH)
52  	private final String propertyPath;
53  
54  	@XmlElements(value = {
55              @XmlElement(name = CriteriaStringValue.Constants.ROOT_ELEMENT_NAME, type = CriteriaStringValue.class, required = true),
56              @XmlElement(name = CriteriaPropertyPathValue.Constants.ROOT_ELEMENT_NAME, type = CriteriaPropertyPathValue.class, required = true),
57  			@XmlElement(name = CriteriaDecimalValue.Constants.ROOT_ELEMENT_NAME, type = CriteriaDecimalValue.class, required = true),
58              @XmlElement(name = CriteriaKualiDecimalValue.Constants.ROOT_ELEMENT_NAME, type = CriteriaKualiDecimalValue.class, required = true),
59              @XmlElement(name = CriteriaKualiPercentValue.Constants.ROOT_ELEMENT_NAME, type = CriteriaKualiPercentValue.class, required = true),
60              @XmlElement(name = CriteriaKualiIntegerValue.Constants.ROOT_ELEMENT_NAME, type = CriteriaKualiIntegerValue.class, required = true),
61              @XmlElement(name = CriteriaIntegerValue.Constants.ROOT_ELEMENT_NAME, type = CriteriaIntegerValue.class, required = true),
62              @XmlElement(name = CriteriaDateTimeValue.Constants.ROOT_ELEMENT_NAME, type = CriteriaDateTimeValue.class, required = true)
63      })
64  	private final CriteriaValue<?> value;
65  
66      @XmlAnyElement
67      private final Collection<Element> _futureElements = null;
68  	
69  	/**
70       * Should only be invoked by JAXB.
71       */
72      @SuppressWarnings("unused")
73      private GreaterThanOrEqualPredicate() {
74          this.propertyPath = null;
75          this.value = null;
76      }
77      
78      /**
79  	 * Constructs a GreaterThanOrEqualPredicate for the given path and value.  GreaterThanOrEqualPredicate supports the following {@link CriteriaValue}:
80  	 * 
81  	 * <ul>
82  	 *   <li>{@link CriteriaDateTimeValue}</li>
83  	 *   <li>{@link CriteriaDecimalValue}</li>
84  	 *   <li>{@link CriteriaIntegerValue}</li>
85       *   <li>{@link CriteriaKualiDecimalValue}</li>
86       *   <li>{@link CriteriaKualiPercentValue}</li>
87  	 * </ul>
88  	 * 
89  	 * @param propertyPath the property path for the predicate, must not be null or blank
90  	 * @param value the value to evaluation the path against, must not be null.
91  	 * 
92  	 * @throws IllegalArgumentException if the propertyPath is null or blank
93  	 * @throws IllegalArgumentException if the value is null
94  	 * @throws IllegalArgumentException if this predicate does not support the given type of {@link CriteriaValue}
95  	 */
96      GreaterThanOrEqualPredicate(String propertyPath, CriteriaValue<?> value) {
97      	CriteriaSupportUtils.validateValuedConstruction(getClass(), propertyPath, value);
98  		this.propertyPath = propertyPath;
99  		this.value = value;
100     }
101     
102     @Override
103     public String getPropertyPath() {
104     	return propertyPath;
105     }
106     
107 	@Override
108 	public CriteriaValue<?> getValue() {
109 		return value;
110 	}
111     
112 	/**
113      * Defines some internal constants used on this class.
114      */
115     static class Constants {
116         final static String ROOT_ELEMENT_NAME = "greaterThanOrEqual";
117         final static String TYPE_NAME = "GreaterThanOrEqualType";
118     }
119 
120     @Override
121     public String toString() {
122         return CriteriaSupportUtils.toString(this);
123     }
124     
125 }