Coverage Report - org.kuali.rice.core.api.criteria.EqualExpression
 
Classes in this File Line Coverage Branch Coverage Complexity
EqualExpression
100%
12/12
N/A
1
EqualExpression$Constants
0%
0/1
N/A
1
 
 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 javax.xml.bind.annotation.XmlAccessType;
 19  
 import javax.xml.bind.annotation.XmlAccessorType;
 20  
 import javax.xml.bind.annotation.XmlAttribute;
 21  
 import javax.xml.bind.annotation.XmlElement;
 22  
 import javax.xml.bind.annotation.XmlElements;
 23  
 import javax.xml.bind.annotation.XmlRootElement;
 24  
 import javax.xml.bind.annotation.XmlType;
 25  
 
 26  
 /**
 27  
  * An immutable expression which represents an "equal" statement which is
 28  
  * evaluated the {@link CriteriaValue} of this expression.
 29  
  * 
 30  
  * <p>Constructed as part of a {@link Criteria} when built using a
 31  
  * {@link CriteriaBuilder}.
 32  
  * 
 33  
  * @see Criteria
 34  
  * @see CriteriaBuilder
 35  
  * 
 36  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 37  
  * 
 38  
  */
 39  18
 @XmlRootElement(name = EqualExpression.Constants.ROOT_ELEMENT_NAME)
 40  
 @XmlAccessorType(XmlAccessType.NONE)
 41  
 @XmlType(name = EqualExpression.Constants.TYPE_NAME)
 42  
 public final class EqualExpression extends AbstractExpression implements ValuedExpression {
 43  
         
 44  
         private static final long serialVersionUID = 7159459561133496549L;
 45  
         
 46  
         @XmlAttribute(name = CriteriaSupportUtils.PropertyConstants.PROPERTY_PATH)
 47  
         private final String propertyPath;
 48  
         @XmlElements(value = {
 49  
                     @XmlElement(name = CriteriaStringValue.Constants.ROOT_ELEMENT_NAME, type = CriteriaStringValue.class, required = true),
 50  
                     @XmlElement(name = CriteriaDateTimeValue.Constants.ROOT_ELEMENT_NAME, type = CriteriaDateTimeValue.class, required = true),
 51  
                     @XmlElement(name = CriteriaDecimalValue.Constants.ROOT_ELEMENT_NAME, type = CriteriaDecimalValue.class, required = true),
 52  
                     @XmlElement(name = CriteriaIntegerValue.Constants.ROOT_ELEMENT_NAME, type = CriteriaIntegerValue.class, required = true)
 53  
     })
 54  
         private final CriteriaValue<?> value;
 55  
         
 56  
     /**
 57  
      * Should only be invoked by JAXB.
 58  
      */
 59  
     @SuppressWarnings("unused")
 60  18
     private EqualExpression() {
 61  18
         this.propertyPath = null;
 62  18
         this.value = null;
 63  18
     }
 64  
     
 65  
     /**
 66  
          * Constructs an EqualExpression for the given path and value.  EqualExpression supports the following {@link CriteriaValue}:
 67  
          * 
 68  
          * <ul>
 69  
          *   <li>{@link CriteriaStringValue}</li>
 70  
          *   <li>{@link CriteriaDateTimeValue}</li>
 71  
          *   <li>{@link CriteriaDecimalValue}</li>
 72  
          *   <li>{@link CriteriaIntegerValue}</li>
 73  
          * </ul>
 74  
          * 
 75  
          * @param propertyPath the property path for the expression, must not be null or blank
 76  
          * @param value the value to evaluation the path against, must not be null.
 77  
          * 
 78  
          * @throws IllegalArgumentException if the propertyPath is null or blank
 79  
          * @throws IllegalArgumentException if the value is null
 80  
          * @throws IllegalArgumentException if this expression does not support the given type of {@link CriteriaValue}
 81  
          */
 82  28
     EqualExpression(String propertyPath, CriteriaValue<?> value) {
 83  28
             CriteriaSupportUtils.validateValuedExpressionConstruction(getClass(), propertyPath, value);
 84  26
                 this.propertyPath = propertyPath;
 85  26
                 this.value = value;
 86  26
     }
 87  
         
 88  
     @Override
 89  
     public String getPropertyPath() {
 90  6
             return propertyPath;
 91  
     }
 92  
     
 93  
         @Override
 94  
         public CriteriaValue<?> getValue() {
 95  6
                 return value;
 96  
         }
 97  
     
 98  
         /**
 99  
      * Defines some internal constants used on this class.
 100  
      */
 101  0
     static class Constants {
 102  
         final static String ROOT_ELEMENT_NAME = "equal";
 103  
         final static String TYPE_NAME = "EqualType";
 104  
     }
 105  
     
 106  
 }