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 theenumconstant matchingnameas anOptional; otherwise, returns empty. Thenamemust 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- TheClassobject of the enum classname- The name of the constant to return- Returns:
- an
Optionalcontaining theenumconstant if found - Throws:
NullPointerException- iftypeornameisnull
-
ofIgnoreCase
Returns theenumconstant matchingnameas anOptional; otherwise, returns empty. Thenamecomparison 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- TheClassobject of the enum classname- The name of the constant to return- Returns:
- an
Optionalcontaining theenumconstant if found - Throws:
NullPointerException- iftypeornameisnull
-