@Test public void testEquals() { assertEquals(OptionalBoolean.empty(), OptionalBoolean.empty()); assertNotEquals(OptionalBoolean.empty(), Optional.empty()); assertEquals(OptionalBoolean.of(true), OptionalBoolean.of(true)); assertNotEquals(OptionalBoolean.of(false), OptionalBoolean.of(true)); assertNotEquals(OptionalBoolean.of(false), OptionalBoolean.empty()); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof OptionalBoolean)) { return false; } OptionalBoolean other = (OptionalBoolean) obj; return (isPresent && other.isPresent) ? value == other.value : isPresent == other.isPresent; }
OptionalBoolean { @Override public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof OptionalBoolean)) { return false; } OptionalBoolean other = (OptionalBoolean) obj; return (isPresent && other.isPresent) ? value == other.value : isPresent == other.isPresent; } }
OptionalBoolean { @Override public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof OptionalBoolean)) { return false; } OptionalBoolean other = (OptionalBoolean) obj; return (isPresent && other.isPresent) ? value == other.value : isPresent == other.isPresent; } private  OptionalBoolean(); private  OptionalBoolean(boolean value); }
OptionalBoolean { @Override public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof OptionalBoolean)) { return false; } OptionalBoolean other = (OptionalBoolean) obj; return (isPresent && other.isPresent) ? value == other.value : isPresent == other.isPresent; } 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 { @Override public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof OptionalBoolean)) { return false; } OptionalBoolean other = (OptionalBoolean) obj; return (isPresent && other.isPresent) ? value == other.value : isPresent == other.isPresent; } 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();  }