@Test public void testOfNullable() { Assert.assertFalse(Optional.ofNullable(null).isPresent()); Assert.assertTrue(Optional.ofNullable(1).isPresent()); Assert.assertEquals(Optional.ofNullable(1).get(), Integer.valueOf(1)); }
public static <T> Optional<T> ofNullable(final T value) { if (null == value) { return Optional.empty(); } else { return Optional.of(value); } }
Optional implements Serializable { public static <T> Optional<T> ofNullable(final T value) { if (null == value) { return Optional.empty(); } else { return Optional.of(value); } } }
Optional implements Serializable { public static <T> Optional<T> ofNullable(final T value) { if (null == value) { return Optional.empty(); } else { return Optional.of(value); } } private  Optional(final T value); private  Optional(); }
Optional implements Serializable { public static <T> Optional<T> ofNullable(final T value) { if (null == value) { return Optional.empty(); } else { return Optional.of(value); } } private  Optional(final T value); private  Optional(); static Optional<T> of(final T value); static Optional<T> empty(); static Optional<T> ofNullable(final T value); T get(); T orElse(final T other); boolean isPresent(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString(); }
Optional implements Serializable { public static <T> Optional<T> ofNullable(final T value) { if (null == value) { return Optional.empty(); } else { return Optional.of(value); } } private  Optional(final T value); private  Optional(); static Optional<T> of(final T value); static Optional<T> empty(); static Optional<T> ofNullable(final T value); T get(); T orElse(final T other); boolean isPresent(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString();  }