001 /**
002 * Copyright 2005-2011 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.rice.krad.uif.util;
017
018 import org.apache.commons.lang.StringUtils;
019
020 /**
021 * Defines functions that can be used in el expressions within
022 * the UIF dictionary files
023 *
024 * @author Kuali Rice Team (rice.collab@kuali.org)
025 */
026 public class ExpressionFunctions {
027
028 /**
029 * Checks whether the given class parameter is assignable from the given object class
030 * parameter
031 *
032 * @param assignableClass - class to use for assignable to
033 * @param objectClass - class to use for assignable from
034 * @return boolean true if the object class is of type assignable class, false if not
035 */
036 public static boolean isAssignableFrom(Class<?> assignableClass, Class<?> objectClass) {
037 return assignableClass.isAssignableFrom(objectClass);
038 }
039
040 /**
041 * Checks whether the given value is null or blank string
042 *
043 * @param value - property value to check
044 * @return boolean true if value is null or blank, false if not
045 */
046 public static boolean empty(Object value) {
047 return (value == null) || (StringUtils.isBlank(value.toString()));
048 }
049
050 /**
051 * Returns the name for the given class
052 *
053 * @param clazz - class object to return name for
054 * @return String class name or empty string if class is null
055 */
056 public static String getName(Class<?> clazz) {
057 if (clazz == null) {
058 return "";
059 } else {
060 return clazz.getName();
061 }
062 }
063 }