diff --git a/src/main/java/net/kemitix/mon/maybe/Maybe.java b/src/main/java/net/kemitix/mon/maybe/Maybe.java index c26ed13..e12e83b 100644 --- a/src/main/java/net/kemitix/mon/maybe/Maybe.java +++ b/src/main/java/net/kemitix/mon/maybe/Maybe.java @@ -24,8 +24,6 @@ package net.kemitix.mon.maybe; import lombok.NonNull; import net.kemitix.mon.Functor; -import java.util.Optional; - /** * A value that may or may not be present. * @@ -74,21 +72,4 @@ public interface Maybe extends Functor>, MaybeStream, MaybeOpt return just(value); } - /** - * Create a Maybe from an {@link Optional}. - * - * @param optional the Optional - * @param the type of the Optional - * - * @return a Maybe - * @deprecated need to find a better way of converting an Optional to a Maybe, but - * without having to pass the Optional as a parameter - * Try: Optional.of(1).map(Maybe::just).orElse(Maybe::nothing) - */ - @Deprecated - static Maybe fromOptional(final Optional optional) { - return optional.map(Maybe::maybe) - .orElse(nothing()); - } - } diff --git a/src/test/java/net/kemitix/mon/MaybeTest.java b/src/test/java/net/kemitix/mon/MaybeTest.java index 4f3b31b..bbe60c5 100644 --- a/src/test/java/net/kemitix/mon/MaybeTest.java +++ b/src/test/java/net/kemitix/mon/MaybeTest.java @@ -85,10 +85,6 @@ public class MaybeTest implements WithAssertions { @Test public void fromOptional() { - // deprecated methods - assertThat(Maybe.fromOptional(Optional.of(1))).isEqualTo(just(1)); - assertThat(Maybe.fromOptional(Optional.empty())).isEqualTo(nothing()); - // recommended alternative assertThat(Optional.of(1).map(Maybe::just).orElseGet(Maybe::nothing)).isEqualTo(just(1)); assertThat(Optional.empty().map(Maybe::just).orElseGet(Maybe::nothing)).isEqualTo(nothing()); }