@Test public void equalsOfValueDoesNotEqualsAnother() throws Exception { Assert.assertNotEquals(Optional.of(1), Optional.of(2)); }
public static <T> Optional<T> of(T value) { if (value == null) { throw new NullPointerException(); } return new Optional<T>(value); }
Optional { public static <T> Optional<T> of(T value) { if (value == null) { throw new NullPointerException(); } return new Optional<T>(value); } }
Optional { public static <T> Optional<T> of(T value) { if (value == null) { throw new NullPointerException(); } return new Optional<T>(value); } private  Optional(T value); }
Optional { public static <T> Optional<T> of(T value) { if (value == null) { throw new NullPointerException(); } return new Optional<T>(value); } private  Optional(T value); @SuppressWarnings("unchecked") static Optional<T> empty(); static Optional<T> of(T value); static Optional<T> ofNullable(T value); Optional<T> filter(Predicate<? super T> predicate); Optional<U> flatMap(Function<? super T, Optional<U>> mapper); T get(); void ifPresent(Consumer<? super T> consumer); void ifPresentOrElse(Consumer<? super T> consumer, Runnable emptyAction); boolean isPresent(); Optional<U> map(Function<? super T, ? extends U> mapper); Optional<T> or(Supplier<? extends Optional<? extends T>> supplier); T orElse(T other); T orElseGet(Supplier<? extends T> other); T orElseThrow(Supplier<? extends X> exceptionSupplier); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
Optional { public static <T> Optional<T> of(T value) { if (value == null) { throw new NullPointerException(); } return new Optional<T>(value); } private  Optional(T value); @SuppressWarnings("unchecked") static Optional<T> empty(); static Optional<T> of(T value); static Optional<T> ofNullable(T value); Optional<T> filter(Predicate<? super T> predicate); Optional<U> flatMap(Function<? super T, Optional<U>> mapper); T get(); void ifPresent(Consumer<? super T> consumer); void ifPresentOrElse(Consumer<? super T> consumer, Runnable emptyAction); boolean isPresent(); Optional<U> map(Function<? super T, ? extends U> mapper); Optional<T> or(Supplier<? extends Optional<? extends T>> supplier); T orElse(T other); T orElseGet(Supplier<? extends T> other); T orElseThrow(Supplier<? extends X> exceptionSupplier); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }