CriteriaMatcherInMemory { protected static Object extractValue(String fieldPath, Object infoObject) { try { if (infoObject == null) { return null; } Object value = PropertyUtils.getNestedProperty(infoObject, fieldPath); if (value instanceof Boolean) { return value.toString(); } 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); } } CriteriaMatcherInMemory(); QueryByCriteria getCriteria(); void setCriteria(QueryByCriteria criteria); Collection<T> findMatching(Collection<T> all); boolean matches(T infoObject); static boolean matchesEqual(Object dataValue, Object criteriaValue); static boolean matchesLessThan(Object dataValue, Object criteriaValue); static boolean matchesGreaterThan(Object dataValue, Object criteriaValue); boolean matchesLike(Object dataValue, Object criteriaValue); boolean matchesLikeCachingPattern(final String str, final String expr); static boolean matchesLike(final String str, final String expr);  }
@Test public void testExtractValue() { ContextDefinition org = this.getTestContexts().get(0); assertEquals("ID-AA", CriteriaMatcherInMemory.extractValue("id", org)); assertEquals("AA", CriteriaMatcherInMemory.extractValue("namespace", org)); assertEquals("Automobile Association", CriteriaMatcherInMemory.extractValue("name", org)); assertEquals("Consumer", CriteriaMatcherInMemory.extractValue("typeId", org)); assertEquals("true", CriteriaMatcherInMemory.extractValue("active", org)); assertEquals("Automobile Association towing", CriteriaMatcherInMemory.extractValue("description", org)); }