/** * fetching a value from given object * * @param obj * - a {@link java.lang.Object} * @return object - a {@link java.lang.Object} - return of given method * @throws InvocationTargetException * @throws IllegalAccessException * @throws NoSuchMethodException */ private Object getValue(Object obj) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException { return invoke(getMethod(obj), obj); }
/** * {@inheritDoc} */ @Override public int compare(Object o1, Object o2) { int response = LESSER; try { Object v1 = (null == this.targetMethod) ? o1 : getValue(o1); Object v2 = (null == this.targetMethod) ? o2 : getValue(o2); CompareMode cm = findCompareMode(v1, v2); if (!cm.equals(CompareMode.DEFAULT)) { return compareAlternate(cm); } final String returnType = (null == this.targetMethod) ? o1.getClass().getName() : getMethod(o1).getReturnType().getName(); response = compareActual(v1, v2, returnType); } catch (NoSuchMethodException nsme) { LOGGER.error("NoSuchMethodException occurred while comparing", nsme); } catch (IllegalAccessException iae) { LOGGER.error("IllegalAccessException occurred while comparing", iae); } catch (InvocationTargetException ite) { LOGGER.error("InvocationTargetException occurred while comparing", ite); } return response; }