Package io.blt.util
Class En
java.lang.Object
io.blt.util.En
Static utility methods for operating on
Enum
.-
Method Summary
-
Method Details
-
of
Returns theenum
constant matchingname
as anOptional
; otherwise, returns empty. Thename
must match exactly.This method will not throw for an invalid enum name and instead will return empty.
e.g.,of(DayOfWeek.class, "FRIDAY"); // Optional.of(DayOfWeek.FRIDAY) of(DayOfWeek.class, "friday"); // Optional.empty() of(DayOfWeek.class, "Worf"); // Optional.empty() of(DayOfWeek.class, ""); // Optional.empty()
- Type Parameters:
E
- The type of theEnum
- Parameters:
type
- TheClass
object of the enum classname
- The name of the constant to return- Returns:
- an
Optional
containing theenum
constant if found - Throws:
NullPointerException
- iftype
orname
isnull
-
ofIgnoreCase
Returns theenum
constant matchingname
as anOptional
; otherwise, returns empty. Thename
comparison is case-insensitive.This method will not throw for an invalid enum name and instead will return empty.
ofIgnoreCase(DayOfWeek.class, "FRIDAY"); // Optional.of(DayOfWeek.FRIDAY) ofIgnoreCase(DayOfWeek.class, "friday"); // Optional.of(DayOfWeek.FRIDAY) ofIgnoreCase(DayOfWeek.class, "Worf"); // Optional.empty() ofIgnoreCase(DayOfWeek.class, ""); // Optional.empty()
- Type Parameters:
E
- The type of theEnum
- Parameters:
type
- TheClass
object of the enum classname
- The name of the constant to return- Returns:
- an
Optional
containing theenum
constant if found - Throws:
NullPointerException
- iftype
orname
isnull
-