class CriteriaMatcherInMemory {

    protected static Object extractValue(String fieldPath, Object infoObject) {

        try {
            if (infoObject == null) {
                return null;
            }
            Object value = PropertyUtils.getNestedProperty(infoObject, fieldPath);
            // translate boolean to string so we can compare
            // Have to do this because RICE's predicate does not support boolean 
            // because it is database oriented and most DB do not support booleans natively.
            if (value instanceof Boolean) {
                return value.toString();
            }
            // See Rice's CriteriaSupportUtils.determineCriteriaValue where data normalized 
            // translate date to joda DateTime because that is what RICE PredicateFactory does 
            // similar to rest of the types 
            if (value instanceof Date) {
                return new DateTime ((Date) value);
            }
            if (value instanceof Calendar) {
                return new DateTime ((Calendar) value);
            }
            if (value instanceof Short) {
                return BigInteger.valueOf(((Short) value).longValue());
            }
            if (value instanceof AtomicLong) {
                return BigInteger.valueOf(((AtomicLong) value).longValue());
            }
            if (value instanceof AtomicInteger) {
                return BigInteger.valueOf(((AtomicInteger) value).longValue());
            }
            if (value instanceof Integer) {
                return BigInteger.valueOf(((Integer)value).longValue());
            }
            if (value instanceof Long) {
                return BigInteger.valueOf(((Long)value).longValue());
            }
            if (value instanceof Float) {
                return BigDecimal.valueOf(((Float)value).doubleValue());
            }
            if (value instanceof Double) {
                return BigDecimal.valueOf(((Double)value).doubleValue());
            }
            return value;
        } catch (NestedNullException ex) {
            return null;
        }  catch (IllegalAccessException ex) {
            throw new IllegalArgumentException(fieldPath, ex);
        } catch (InvocationTargetException ex) {
            throw new IllegalArgumentException(fieldPath, ex);
        } catch (NoSuchMethodException ex) {
            throw new IllegalArgumentException(fieldPath, ex);
        }
//        }
//        return value;
    }

    public  CriteriaMatcherInMemory();

}