Coverage Report - org.kuali.rice.core.api.criteria.AbstractCompositeExpression
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractCompositeExpression
100%
9/9
100%
2/2
1.333
AbstractCompositeExpression$Constants
0%
0/1
N/A
1.333
 
 1  
 /*
 2  
  * Copyright 2011 The Kuali Foundation Licensed under the Educational Community License, Version 1.0 (the "License"); you may
 3  
  * not use this file except in compliance with the License. You may obtain a copy of the License at
 4  
  * http://www.opensource.org/licenses/ecl1.php Unless required by applicable law or agreed to in writing, software
 5  
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 6  
  * express or implied. See the License for the specific language governing permissions and limitations under the License.
 7  
  */
 8  
 package org.kuali.rice.core.api.criteria;
 9  
 
 10  
 import java.util.ArrayList;
 11  
 import java.util.Collections;
 12  
 import java.util.List;
 13  
 
 14  
 import javax.xml.bind.annotation.XmlAccessType;
 15  
 import javax.xml.bind.annotation.XmlAccessorType;
 16  
 import javax.xml.bind.annotation.XmlElement;
 17  
 import javax.xml.bind.annotation.XmlElements;
 18  
 import javax.xml.bind.annotation.XmlType;
 19  
 
 20  
 /**
 21  
  * An abstract implementation of a {@link CompositeExpression}.  This class defines all of the JAXB
 22  
  * annotations such that sub-classes should not have to.
 23  
  * 
 24  
  * <p>If a class subclasses this class then it *MUST* be sure to add itself to the JAXB
 25  
  * annotations for {@link #expressions}
 26  
  * 
 27  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 28  
  */
 29  
 @XmlAccessorType(XmlAccessType.NONE)
 30  
 @XmlType(name = AbstractCompositeExpression.Constants.TYPE_NAME)
 31  
 abstract class AbstractCompositeExpression extends AbstractExpression implements CompositeExpression {
 32  
 
 33  
     private static final long serialVersionUID = 6164560054223588779L;
 34  
     
 35  
     /**
 36  
      * Defines the JAXB annotations for the List of expressions.  All supported expressions *MUST* be
 37  
      * included in this List in order for them to be supported in the XML schema.
 38  
      * 
 39  
      * If a new type of expression is created it *MUST* be added to this list.
 40  
      */
 41  
         @XmlElements(value = {
 42  
             @XmlElement(name = AndExpression.Constants.ROOT_ELEMENT_NAME, type = AndExpression.class, required = true),
 43  
             @XmlElement(name = OrExpression.Constants.ROOT_ELEMENT_NAME, type = OrExpression.class, required = true),
 44  
             @XmlElement(name = EqualExpression.Constants.ROOT_ELEMENT_NAME, type = EqualExpression.class, required = true),
 45  
             @XmlElement(name = NotEqualExpression.Constants.ROOT_ELEMENT_NAME, type = NotEqualExpression.class, required = true),
 46  
             @XmlElement(name = LikeExpression.Constants.ROOT_ELEMENT_NAME, type = LikeExpression.class, required = true),
 47  
             @XmlElement(name = InExpression.Constants.ROOT_ELEMENT_NAME, type = InExpression.class, required = true),
 48  
             @XmlElement(name = NotInExpression.Constants.ROOT_ELEMENT_NAME, type = NotInExpression.class, required = true),
 49  
             @XmlElement(name = GreaterThanExpression.Constants.ROOT_ELEMENT_NAME, type = GreaterThanExpression.class, required = true),
 50  
             @XmlElement(name = GreaterThanOrEqualExpression.Constants.ROOT_ELEMENT_NAME, type = GreaterThanOrEqualExpression.class, required = true),
 51  
             @XmlElement(name = LessThanExpression.Constants.ROOT_ELEMENT_NAME, type = LessThanExpression.class, required = true),
 52  
             @XmlElement(name = LessThanOrEqualExpression.Constants.ROOT_ELEMENT_NAME, type = LessThanOrEqualExpression.class, required = true),
 53  
             @XmlElement(name = NullExpression.Constants.ROOT_ELEMENT_NAME, type = NullExpression.class, required = true),
 54  
             @XmlElement(name = NotNullExpression.Constants.ROOT_ELEMENT_NAME, type = NotNullExpression.class, required = true)
 55  
     })
 56  
     private final List<Expression> expressions;
 57  
 
 58  
         /**
 59  
          * This default constructor exists only to be invoked by sub-classes
 60  
          * in their default constructors which is used by JAXB. 
 61  
          */
 62  20
     AbstractCompositeExpression() {
 63  20
         this.expressions = null;
 64  20
     }
 65  
 
 66  
     /**
 67  
      * When invoked by a subclass, this constructor will set the expressions
 68  
      * to the given list. If the list is null then it will be translated
 69  
      * internally to an empty list.
 70  
      * 
 71  
      * @param expressions the list of expressions to set
 72  
      */
 73  30
     AbstractCompositeExpression(final List<Expression> expressions) {
 74  30
         if (expressions == null) {
 75  4
             this.expressions = new ArrayList<Expression>();
 76  
         } else {
 77  26
             this.expressions = new ArrayList<Expression>(expressions);
 78  
         }
 79  30
     }
 80  
 
 81  
     @Override
 82  
     public List<Expression> getExpressions() {
 83  23
         return Collections.unmodifiableList(expressions);
 84  
     }
 85  
 
 86  
     /**
 87  
      * Defines some internal constants used on this class.
 88  
      */
 89  0
     static class Constants {
 90  
         final static String TYPE_NAME = "CompositeExpressionType";
 91  
     }
 92  
 
 93  
 }