### Question:
Optional implements
        Conditional<Optional<T>, T>,
        Internal<Optional<T>, T>,
        Function<Consumer<T>, Optional<T>>,
        DefaultIfEmpty<T>,
        Functor<T> { public Optional<T> debug(Consumer<T> action) { if (chain.configuration.isDebugging() && chain.item != null) { Invoker.invoke(action, chain.item); } return new Optional<>(chain.item, chain.configuration); } Optional(T item, InternalConfiguration configuration); @Override Chain<T> defaultIfEmpty(@NonNull T defaultValue); Optional<T> apply(Consumer<T> action); Optional<T> invoke(Action action); Optional<R> map(Function<T, R> mapper); Maybe<R> flatMapMaybe(Function<T, R> flatMapper); Optional<R> to(@NonNull R item); Optional<R> to(@NonNull Callable<R> itemCallable); Maybe<T> toMaybe(); Logger<Optional<T>, T> log(Object tag); Optional<T> debug(Consumer<T> action); Condition<Optional<T>, T> when(Predicate<T> predicate); Condition<Optional<T>, T> whenNot(Predicate<T> predicate); Condition<Optional<T>, T> whenIn(Collection<T> collection); Condition<Optional<T>, T> whenIn(Collection<T> collection, BiPredicate<T, T> comparator); Condition<Optional<T>, T> whenNotIn(Collection<T> collection); Condition<Optional<T>, T> whenNotIn(Collection<T> collection, BiPredicate<T, T> comparator); @NonNull T callOrCrash(); @NonNull T callOrCrash(String crashMessage); @Override Proxy<Optional<T>, T> access();  }### Answer:
@Test public void debugWhileChainConfigIsDebuggingThenInvokeDebug() { InternalConfiguration config = InternalConfiguration .getInstance("debugWhileChainConfigIsDebuggingThenInvokeDebug"); config.setDebugging(true); final boolean[] result = {false}; new Optional<>(new TestClass(), config) .debug(new Consumer<TestClass>() { @Override public void accept(@NonNull TestClass testClass) throws Exception { result[0] = true; } }); assertTrue(result[0]); }
@Test public void debugWhileChainConfigIsNotDebuggingThenDoNotInvokeDebug() { InternalConfiguration config = InternalConfiguration .getInstance("debugWhileChainConfigIsNotDebuggingThenDoNotInvokeDebug"); config.setDebugging(false); final boolean[] result = {false}; new Optional<>(new TestClass(), config) .debug(new Consumer<TestClass>() { @Override public void accept(@NonNull TestClass testClass) throws Exception { result[0] = true; } }); assertFalse(result[0]); }