/** * <p> * Return {@link Some} containing {@code x}. * </p> * * @param <T> The type of values * @param x The value * * @return An optional value */ public static <T> OptionType<T> some( final T x) { return Some.some(x); } }
/** * <p> * If {@code x == null}, return {@link None}, else return {@link Some} * containing {@code x}. * </p> * * @param <T> The type of values * @param x The value * * @return An optional value */ public static <T> OptionType<T> of( final @Nullable T x) { if (x == null) { return None.none(); } return Some.some(x); }