Coverage Report - org.kuali.rice.core.api.criteria.NotNullPredicate
 
Classes in this File Line Coverage Branch Coverage Complexity
NotNullPredicate
83%
10/12
100%
2/2
1.5
NotNullPredicate$Constants
0%
0/1
N/A
1.5
 
 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 org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.core.api.CoreConstants;
 20  
 import org.w3c.dom.Element;
 21  
 
 22  
 import javax.xml.bind.annotation.XmlAccessType;
 23  
 import javax.xml.bind.annotation.XmlAccessorType;
 24  
 import javax.xml.bind.annotation.XmlAnyElement;
 25  
 import javax.xml.bind.annotation.XmlAttribute;
 26  
 import javax.xml.bind.annotation.XmlRootElement;
 27  
 import javax.xml.bind.annotation.XmlType;
 28  
 import java.util.Collection;
 29  
 
 30  
 /**
 31  
  * An immutable predicate which represents an "is not null" statement which is
 32  
  * evaluated the property defined by the property path on this predicate.
 33  
  *
 34  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 35  
  * @see PredicateFactory for a convenient way to construct this class.
 36  
  */
 37  14
 @XmlRootElement(name = NotNullPredicate.Constants.ROOT_ELEMENT_NAME)
 38  
 @XmlAccessorType(XmlAccessType.NONE)
 39  
 @XmlType(name = NotNullPredicate.Constants.TYPE_NAME, propOrder = {CoreConstants.CommonElements.FUTURE_ELEMENTS})
 40  
 public final class NotNullPredicate extends AbstractPredicate implements PropertyPathPredicate {
 41  
 
 42  
     private static final long serialVersionUID = 6723462533500402423L;
 43  
 
 44  
     @XmlAttribute(name = CriteriaSupportUtils.PropertyConstants.PROPERTY_PATH)
 45  
     private final String propertyPath;
 46  
 
 47  8
     @SuppressWarnings("unused")
 48  
     @XmlAnyElement
 49  
     private final Collection<Element> _futureElements = null;
 50  
 
 51  
     /**
 52  
      * Should only be invoked by JAXB.
 53  
      */
 54  
     @SuppressWarnings("unused")
 55  2
     private NotNullPredicate() {
 56  2
         this.propertyPath = null;
 57  2
     }
 58  
 
 59  
     /**
 60  
      * Constructs a NotNullPredicate for the given propertyPath.
 61  
      *
 62  
      * @param propertyPath the property path for the predicate, must not be null or blank
 63  
      * @throws IllegalArgumentException if the propertyPath is null or blank
 64  
      */
 65  6
     NotNullPredicate(String propertyPath) {
 66  6
         if (StringUtils.isBlank(propertyPath)) {
 67  2
             throw new IllegalArgumentException("Property path cannot be null or blank.");
 68  
         }
 69  4
         this.propertyPath = propertyPath;
 70  4
     }
 71  
 
 72  
     @Override
 73  
     public String getPropertyPath() {
 74  0
         return propertyPath;
 75  
     }
 76  
 
 77  
     /**
 78  
      * Defines some internal constants used on this class.
 79  
      */
 80  0
     static class Constants {
 81  
         final static String ROOT_ELEMENT_NAME = "notNull";
 82  
         final static String TYPE_NAME = "NotNullType";
 83  
     }
 84  
 
 85  
     @Override
 86  
     public String toString() {
 87  0
         return new StringBuilder(CriteriaSupportUtils.findDynName(this.getClass().getSimpleName()))
 88  
                 .append(this.getPropertyPath()).append(")").toString();
 89  
     }
 90  
 }