Example usage for org.springframework.security.util FieldUtils getFieldValue

List of usage examples for org.springframework.security.util FieldUtils getFieldValue

Introduction

In this page you can find the example usage for org.springframework.security.util FieldUtils getFieldValue.

Prototype

public static Object getFieldValue(Object bean, String fieldName) throws IllegalAccessException 

Source Link

Document

Returns the value of a (nested) field on a bean.

Usage

From source file:tds.tdsadmin.model.LazySorter.java

public int compare(TestOpportunity testOpportunity1, TestOpportunity testOpportunity2) {
    try {/*from  w  w  w.ja v a 2 s.  co  m*/

        Object value1 = FieldUtils.getFieldValue(testOpportunity1, sortField);
        Object value2 = FieldUtils.getFieldValue(testOpportunity2, sortField);

        int value;
        if (value1 == null && value2 == null)
            value = 0;
        else if (value1 == null)
            value = -1;
        else if (value2 == null)
            value = 1;
        else
            value = ((Comparable) value1).compareTo(value2);

        return SortOrder.ASCENDING.equals(sortOrder) ? value : -1 * value;
    } catch (Exception e) {
        _logger.error(e.getMessage(), e);
        throw new RuntimeException();
    }
}