// Path: src/main/java/com/hadisatrio/optional/function/Consumer.java
// public interface Consumer<T> {
// 
//     void consume(T value);
// }
// 
// Path: src/main/java/com/hadisatrio/optional/function/Function.java
// public interface Function {
// 
//     void call();
// }
// 
// Path: src/main/java/com/hadisatrio/optional/function/Supplier.java
// public interface Supplier<T> {
// 
//     T get();
// }


import com.hadisatrio.optional.function.Consumer;
import com.hadisatrio.optional.function.Function;
import com.hadisatrio.optional.function.Supplier;
import org.junit.Assert;
import org.junit.Test;
    public void ifPresent() throws Exception {
        Optional.ofNullable("42").ifPresent(new Consumer<String>() {
            @Override
            public void consume(String value) {
                Assert.assertEquals("42", value);
            }
        });

        Optional.ofNullable(null).ifPresent(new Consumer<Object>() {
            @Override
            public void consume(Object value) {
                Assert.fail("ifPresent() on an absent optional should never call its consumer");
            }
        });

        Optional.absent().ifPresent(new Consumer<Object>() {
            @Override
            public void consume(Object value) {
                Assert.fail("ifPresent() on an absent optional should never call its consumer");
            }
        });
    }

    @Test
    public void ifPresentOrElse() throws Exception {
        Optional.ofNullable("42").ifPresentOrElse(new Consumer<String>() {
            @Override
            public void consume(String value) {
                Assert.assertEquals("42", value);
            }
// Path: src/main/java/com/hadisatrio/optional/function/Consumer.java
// public interface Consumer<T> {
// 
//     void consume(T value);
// }
// 
// Path: src/main/java/com/hadisatrio/optional/function/Function.java
// public interface Function {
// 
//     void call();
// }
// 
// Path: src/main/java/com/hadisatrio/optional/function/Supplier.java
// public interface Supplier<T> {
// 
//     T get();
// }


// Path: src/test/java/com/hadisatrio/optional/OptionalTest.java
import com.hadisatrio.optional.function.Consumer;
import com.hadisatrio.optional.function.Function;
import com.hadisatrio.optional.function.Supplier;
import org.junit.Assert;
import org.junit.Test;

    public void ifPresent() throws Exception {
        Optional.ofNullable("42").ifPresent(new Consumer<String>() {
            @Override
            public void consume(String value) {
                Assert.assertEquals("42", value);
            }
        });

        Optional.ofNullable(null).ifPresent(new Consumer<Object>() {
            @Override
            public void consume(Object value) {
                Assert.fail("ifPresent() on an absent optional should never call its consumer");
            }
        });

        Optional.absent().ifPresent(new Consumer<Object>() {
            @Override
            public void consume(Object value) {
                Assert.fail("ifPresent() on an absent optional should never call its consumer");
            }
        });
    }

    @Test
    public void ifPresentOrElse() throws Exception {
        Optional.ofNullable("42").ifPresentOrElse(new Consumer<String>() {
            @Override
            public void consume(String value) {
                Assert.assertEquals("42", value);
            }
        }, new Function() {