/** {@inheritDoc} */ public final Object evaluate() { Object result = null; // if the function returns another function, execute it. stop executing // when the result is not of the expected type. while (true) { result = function.evaluate(); if (functionType.isInstance(result)) { function = (NullaryFunction<?>) result; continue; } else { break; } } return result; }
/** {@inheritDoc} */ @Override public int hashCode() { return "RecursiveEvaluation".hashCode() << 2 ^ function.hashCode(); }
/** * Get the class of the specified object, or <code>null</code> if <code>o</code> is <code>null * </code>. * * @param f Object to check * @return Class found */ private static Class<?> getClass(NullaryFunction<?> f) { return f == null ? null : f.getClass(); }