public class ValidationUtils extends Object
Inherited from Kuali Student and adapted extensively
Modifier and Type | Class and Description |
---|---|
static class |
ValidationUtils.Result
defines possible result values of a comparison operation
|
Constructor and Description |
---|
ValidationUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
buildPath(String attributePath,
String attributeName)
constructs a path by appending the attribute name to the provided path
|
static boolean |
compareValues(Object fieldValue,
Object whenValue,
DataType dataType,
String operator,
boolean isCaseSensitive,
DateTimeService dateTimeService)
compares the value provided by the user and the one specified by the
WhenConstraint |
static Object |
convertToDataType(Object value,
DataType dataType,
DateTimeService dateTimeService)
attempts to convert the provided value to the given dataType
|
static Boolean |
getBoolean(Object o)
converts the provided object into a boolean
|
static Date |
getDate(Object object,
DateTimeService dateTimeService)
determines whether the provided object is a date and tries to converts non-date values
|
static Double |
getDouble(Object o)
converts the provided object into a double
|
static Float |
getFloat(Object o)
converts the provided object into an float
|
static Integer |
getInteger(Object o)
converts the provided object into an integer
|
static int |
getLastPathIndex(String attributePath)
Used to get the rightmost index value of an attribute path.
|
static Long |
getLong(Object o)
converts the provided object into a long
|
static String[] |
getPathTokens(String fieldPath)
converts a path into an array of its path components
|
static String |
getString(Object o)
converts the provided object into a string
|
static boolean |
hasText(String string)
checks whether the string contains non-whitespace characters
|
static <T> ValidationUtils.Result |
isGreaterThan(T value,
Comparable<T> limit)
checks whether the provided value is greater than the limit given
|
static <T> ValidationUtils.Result |
isGreaterThanOrEqual(T value,
Comparable<T> limit)
checks whether the provided value is greater than or equal to the limit given
|
static <T> ValidationUtils.Result |
isLessThan(T value,
Comparable<T> limit)
checks whether the provided value is less than the limit given
|
static <T> ValidationUtils.Result |
isLessThanOrEqual(T value,
Comparable<T> limit)
checks whether the provided value is greater than the limit given
|
static boolean |
isNullOrEmpty(Object value)
checks whether the provided object is null or empty
|
public ValidationUtils()
public static String buildPath(String attributePath, String attributeName)
attributePath
- - a string representation of specifically which attribute (at some depth) is being accessedattributeName
- - the attribute namepublic static int getLastPathIndex(String attributePath)
attributePath
- public static boolean compareValues(Object fieldValue, Object whenValue, DataType dataType, String operator, boolean isCaseSensitive, DateTimeService dateTimeService)
WhenConstraint
fieldValue
- - the value found in the field specified by a CaseConstraint
's propertyName
whenValue
- - the value specified by a WhenConstraint
dataType
- - the data type of the field which caseConstraint's propertyName refers tooperator
- - the relationship to check between the fieldValue
and the whenValue
isCaseSensitive
- - whether string comparison will be carried out in a case sensitive fashiondateTimeService
- - used to convert strings to datespublic static Integer getInteger(Object o)
o
- - the object to convertpublic static Long getLong(Object o)
o
- - the object to convertpublic static Float getFloat(Object o)
o
- - the object to convertpublic static Double getDouble(Object o)
o
- - the object to convertpublic static Date getDate(Object object, DateTimeService dateTimeService) throws IllegalArgumentException
object
- - the object to convert/cast into a datedateTimeService
- - used to convert strings to datesIllegalArgumentException
public static String getString(Object o)
o
- - the object to convertpublic static Boolean getBoolean(Object o)
o
- - the object to convertpublic static boolean hasText(String string)
string
- public static boolean isNullOrEmpty(Object value)
value
- - the object to checkpublic static Object convertToDataType(Object value, DataType dataType, DateTimeService dateTimeService) throws AttributeValidationException
value
- - the object to convertdataType
- - the data type to convert intodateTimeService
- - used to convert strings to datesAttributeValidationException
public static <T> ValidationUtils.Result isGreaterThan(T value, Comparable<T> limit)
T
- value
- - the object to checklimit
- - the limit to useValidationUtils.Result
public static <T> ValidationUtils.Result isGreaterThanOrEqual(T value, Comparable<T> limit)
T
- value
- - the object to checklimit
- - the limit to useValidationUtils.Result
public static <T> ValidationUtils.Result isLessThan(T value, Comparable<T> limit)
T
- value
- - the object to checklimit
- - the limit to useValidationUtils.Result
public static <T> ValidationUtils.Result isLessThanOrEqual(T value, Comparable<T> limit)
T
- value
- - the object to checklimit
- - the limit to useValidationUtils.Result
public static String[] getPathTokens(String fieldPath)
fieldPath
- - a string representation of specifically which attribute (at some depth) is being accessedCopyright © 2005-2015 The Kuali Foundation. All Rights Reserved.