@Test public void testMapToObj() { final BooleanFunction<String> toString = new BooleanFunction<String>() { @Override public String apply(boolean value) { return Boolean.toString(value); } }; Optional<String> result; result = OptionalBoolean.empty().mapToObj(toString); assertThat(result, OptionalMatcher.isEmpty()); result = OptionalBoolean.of(false).mapToObj(toString); assertThat(result, OptionalMatcher.hasValue("false")); result = OptionalBoolean.of(true).mapToObj(toString); assertThat(result, OptionalMatcher.hasValue("true")); result = OptionalBoolean.empty().mapToObj(new BooleanFunction<String>() { @Override public String apply(boolean value) { return null; } }); assertThat(result, OptionalMatcher.isEmpty()); }
@NotNull public <U> Optional<U> mapToObj(@NotNull BooleanFunction<U> mapper) { if (!isPresent()) { return Optional.empty(); } Objects.requireNonNull(mapper); return Optional.ofNullable(mapper.apply(value)); }
OptionalBoolean { @NotNull public <U> Optional<U> mapToObj(@NotNull BooleanFunction<U> mapper) { if (!isPresent()) { return Optional.empty(); } Objects.requireNonNull(mapper); return Optional.ofNullable(mapper.apply(value)); } }
OptionalBoolean { @NotNull public <U> Optional<U> mapToObj(@NotNull BooleanFunction<U> mapper) { if (!isPresent()) { return Optional.empty(); } Objects.requireNonNull(mapper); return Optional.ofNullable(mapper.apply(value)); } private  OptionalBoolean(); private  OptionalBoolean(boolean value); }
OptionalBoolean { @NotNull public <U> Optional<U> mapToObj(@NotNull BooleanFunction<U> mapper) { if (!isPresent()) { return Optional.empty(); } Objects.requireNonNull(mapper); return Optional.ofNullable(mapper.apply(value)); } private  OptionalBoolean(); private  OptionalBoolean(boolean value); @NotNull static OptionalBoolean empty(); @NotNull static OptionalBoolean of(boolean value); @NotNull static OptionalBoolean ofNullable(@Nullable Boolean value); boolean getAsBoolean(); boolean isPresent(); boolean isEmpty(); void ifPresent(@NotNull BooleanConsumer consumer); void ifPresentOrElse(@NotNull BooleanConsumer consumer, @NotNull Runnable emptyAction); @NotNull OptionalBoolean executeIfPresent(@NotNull BooleanConsumer consumer); @NotNull OptionalBoolean executeIfAbsent(@NotNull Runnable action); @Nullable R custom(@NotNull Function<OptionalBoolean, R> function); @NotNull OptionalBoolean filter(@NotNull BooleanPredicate predicate); @NotNull OptionalBoolean filterNot(@NotNull BooleanPredicate predicate); @NotNull OptionalBoolean map(@NotNull BooleanPredicate mapper); @NotNull Optional<U> mapToObj(@NotNull BooleanFunction<U> mapper); @NotNull OptionalBoolean or(@NotNull Supplier<OptionalBoolean> supplier); boolean orElse(boolean other); boolean orElseGet(@NotNull BooleanSupplier other); boolean orElseThrow(); boolean orElseThrow(@NotNull Supplier<X> exceptionSupplier); @Override boolean equals(Object obj); @Override int hashCode(); @NotNull @Override String toString(); }
OptionalBoolean { @NotNull public <U> Optional<U> mapToObj(@NotNull BooleanFunction<U> mapper) { if (!isPresent()) { return Optional.empty(); } Objects.requireNonNull(mapper); return Optional.ofNullable(mapper.apply(value)); } private  OptionalBoolean(); private  OptionalBoolean(boolean value); @NotNull static OptionalBoolean empty(); @NotNull static OptionalBoolean of(boolean value); @NotNull static OptionalBoolean ofNullable(@Nullable Boolean value); boolean getAsBoolean(); boolean isPresent(); boolean isEmpty(); void ifPresent(@NotNull BooleanConsumer consumer); void ifPresentOrElse(@NotNull BooleanConsumer consumer, @NotNull Runnable emptyAction); @NotNull OptionalBoolean executeIfPresent(@NotNull BooleanConsumer consumer); @NotNull OptionalBoolean executeIfAbsent(@NotNull Runnable action); @Nullable R custom(@NotNull Function<OptionalBoolean, R> function); @NotNull OptionalBoolean filter(@NotNull BooleanPredicate predicate); @NotNull OptionalBoolean filterNot(@NotNull BooleanPredicate predicate); @NotNull OptionalBoolean map(@NotNull BooleanPredicate mapper); @NotNull Optional<U> mapToObj(@NotNull BooleanFunction<U> mapper); @NotNull OptionalBoolean or(@NotNull Supplier<OptionalBoolean> supplier); boolean orElse(boolean other); boolean orElseGet(@NotNull BooleanSupplier other); boolean orElseThrow(); boolean orElseThrow(@NotNull Supplier<X> exceptionSupplier); @Override boolean equals(Object obj); @Override int hashCode(); @NotNull @Override String toString();  }