Is it possible to check if the given string matches one of enum-names and then return that enum-element?
I tried this:
boolean isValid = Stream.of(Seniority.values())
.map(Seniority::name)
.collect(Collectors.toList())
.contains(experienceLevel.toUpperCase());
if (isValid) {
return Seniority.valueOf(experienceLevel.toUpperCase());
} else {
return null;
}
Is it possible to do all these actions by using stream only?