OptionalUtil { public static OptionalLong parseLong(String value) { if (value == null) { return OptionalLong.empty(); } else { return OptionalLong.of(Long.parseLong(value)); } } private  OptionalUtil(); static Object unwrap(Object potentiallyOptional); static T unwrap(@SuppressWarnings("OptionalUsedAsFieldOrParameterType") Optional<T> optional); static Integer unwrap(@SuppressWarnings("OptionalUsedAsFieldOrParameterType") OptionalInt optional); static Boolean unwrap(OptionalBoolean optional); static Long unwrap(@SuppressWarnings("OptionalUsedAsFieldOrParameterType") OptionalLong optional); static Double unwrap(@SuppressWarnings("OptionalUsedAsFieldOrParameterType") OptionalDouble optional); static OptionalLong ofNullable(Long l); static OptionalInt ofNullable(Integer i); static OptionalDouble ofNullable(Double d); static OptionalBoolean ofNullable(Boolean b); static OptionalLong parseLong(String value); static OptionalInt parseInt(String value); static OptionalDouble parseDouble(String value); static OptionalBoolean parseBoolean(String value);  }
@Test void parseLong() { assertTrue(OptionalUtil.parseLong("1").isPresent()); assertFalse(OptionalUtil.parseLong(null).isPresent()); }