Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ExpressionFunctions |
|
| 2.0;2 |
1 | /** | |
2 | * Copyright 2005-2011 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.krad.uif.util; | |
17 | ||
18 | import org.apache.commons.lang.StringUtils; | |
19 | ||
20 | /** | |
21 | * Defines functions that can be used in el expressions within | |
22 | * the UIF dictionary files | |
23 | * | |
24 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
25 | */ | |
26 | 0 | public class ExpressionFunctions { |
27 | ||
28 | /** | |
29 | * Checks whether the given class parameter is assignable from the given object class | |
30 | * parameter | |
31 | * | |
32 | * @param assignableClass - class to use for assignable to | |
33 | * @param objectClass - class to use for assignable from | |
34 | * @return boolean true if the object class is of type assignable class, false if not | |
35 | */ | |
36 | public static boolean isAssignableFrom(Class<?> assignableClass, Class<?> objectClass) { | |
37 | 0 | return assignableClass.isAssignableFrom(objectClass); |
38 | } | |
39 | ||
40 | /** | |
41 | * Checks whether the given value is null or blank string | |
42 | * | |
43 | * @param value - property value to check | |
44 | * @return boolean true if value is null or blank, false if not | |
45 | */ | |
46 | public static boolean empty(Object value) { | |
47 | 0 | return (value == null) || (StringUtils.isBlank(value.toString())); |
48 | } | |
49 | ||
50 | /** | |
51 | * Returns the name for the given class | |
52 | * | |
53 | * @param clazz - class object to return name for | |
54 | * @return String class name or empty string if class is null | |
55 | */ | |
56 | public static String getName(Class<?> clazz) { | |
57 | 0 | if (clazz == null) { |
58 | 0 | return ""; |
59 | } else { | |
60 | 0 | return clazz.getName(); |
61 | } | |
62 | } | |
63 | } |