Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
NullExpression |
|
| 1.6666666666666667;1.667 | ||||
NullExpression$Constants |
|
| 1.6666666666666667;1.667 |
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.XmlRootElement; | |
22 | import javax.xml.bind.annotation.XmlType; | |
23 | ||
24 | import org.apache.commons.lang.StringUtils; | |
25 | ||
26 | /** | |
27 | * An immutable expression which represents an "is null" statement which is | |
28 | * evaluated the property defined by the property path on 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 | 2 | @XmlRootElement(name = NullExpression.Constants.ROOT_ELEMENT_NAME) |
40 | @XmlAccessorType(XmlAccessType.NONE) | |
41 | @XmlType(name = NullExpression.Constants.TYPE_NAME) | |
42 | public final class NullExpression extends AbstractExpression implements PropertyPathExpression { | |
43 | ||
44 | private static final long serialVersionUID = 2397296074921454859L; | |
45 | ||
46 | @XmlAttribute(name = CriteriaSupportUtils.PropertyConstants.PROPERTY_PATH) | |
47 | private final String propertyPath; | |
48 | ||
49 | /** | |
50 | * Should only be invoked by JAXB. | |
51 | */ | |
52 | @SuppressWarnings("unused") | |
53 | 2 | private NullExpression() { |
54 | 2 | this.propertyPath = null; |
55 | 2 | } |
56 | ||
57 | /** | |
58 | * Constructs a NullExpression for the given propertyPath. | |
59 | * | |
60 | * @param propertyPath the property path for the expression, must not be null or blank | |
61 | * | |
62 | * @throws IllegalArgumentException if the propertyPath is null or blank | |
63 | */ | |
64 | 3 | NullExpression(String propertyPath) { |
65 | 3 | if (StringUtils.isBlank(propertyPath)) { |
66 | 2 | throw new IllegalArgumentException("Property path cannot be null or blank."); |
67 | } | |
68 | 1 | this.propertyPath = propertyPath; |
69 | 1 | } |
70 | ||
71 | @Override | |
72 | public String getPropertyPath() { | |
73 | 0 | return propertyPath; |
74 | } | |
75 | ||
76 | /** | |
77 | * Defines some internal constants used on this class. | |
78 | */ | |
79 | 0 | static class Constants { |
80 | final static String ROOT_ELEMENT_NAME = "null"; | |
81 | final static String TYPE_NAME = "NullType"; | |
82 | } | |
83 | ||
84 | } |