@Override public boolean apply() { if (!areBothDelegatesValid()) { return false; } if (firstDelegate.needsParameter()) { firstDelegate.invoke(secondDelegate.invoke()); return true; } else if (secondDelegate.needsParameter()) { secondDelegate.invoke(firstDelegate.invoke()); return true; } return false; }
protected boolean areBothDelegatesValid() { return firstDelegate.isValid() && secondDelegate.isValid(); }