@Test public void testOf() { Assert.assertTrue("Optional.of() needs to return an Optional where isPresent() returns true", Optional.of(2).isPresent()); }
public static <T> Optional<T> of(final T value) throws IllegalArgumentException { if (null == value) { throw new IllegalArgumentException("Passed a null value. Use ofNullable() instead"); } return new Optional<>(value); }
Optional implements Serializable { public static <T> Optional<T> of(final T value) throws IllegalArgumentException { if (null == value) { throw new IllegalArgumentException("Passed a null value. Use ofNullable() instead"); } return new Optional<>(value); } }
Optional implements Serializable { public static <T> Optional<T> of(final T value) throws IllegalArgumentException { if (null == value) { throw new IllegalArgumentException("Passed a null value. Use ofNullable() instead"); } return new Optional<>(value); } private  Optional(final T value); private  Optional(); }
Optional implements Serializable { public static <T> Optional<T> of(final T value) throws IllegalArgumentException { if (null == value) { throw new IllegalArgumentException("Passed a null value. Use ofNullable() instead"); } return new Optional<>(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> of(final T value) throws IllegalArgumentException { if (null == value) { throw new IllegalArgumentException("Passed a null value. Use ofNullable() instead"); } return new Optional<>(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();  }