public final class OptionalChar
extends java.lang.Object
char values that may or may not be present. Adapted from OptionalInt and the like.| Modifier and Type | Method and Description |
|---|---|
static OptionalChar |
empty()
Return an empty
OptionalChar. |
boolean |
equals(java.lang.Object o) |
char |
getAsChar()
Get the
char value of this OptionalChar. |
int |
hashCode() |
void |
ifPresent(CharConsumer consumer)
Performs the given action if this
OptionalChar has a value present. |
boolean |
isPresent() |
static OptionalChar |
of(char c)
Return an
OptionalChar with the given char value. |
char |
orElse(char c) |
char |
orElseGet(CharSupplier supplier) |
<T extends java.lang.Throwable> |
orElseThrow(java.util.function.Supplier<T> supplier) |
java.lang.String |
toString() |
public static OptionalChar empty()
OptionalChar.public static OptionalChar of(char c)
OptionalChar with the given char value.public char getAsChar()
char value of this OptionalChar.public boolean isPresent()
OptionalChar has a value present.public void ifPresent(CharConsumer consumer)
OptionalChar has a value present.public char orElse(char c)
OptionalChar if present, otherwise the given char value.public char orElseGet(CharSupplier supplier)
OptionalChar if present, otherwise a value from the given char
supplier.public <T extends java.lang.Throwable> char orElseThrow(java.util.function.Supplier<T> supplier)
throws T extends java.lang.Throwable
OptionalChar if present, otherwise throws an exception from the given
supplier.T extends java.lang.Throwablepublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object