Check valid enum values before using enum

There is an apache commons lang EnumUtils.isValidEnum(). Unfortunately, Under the hood, this is using try/catch logic and returning boolean, but at least your code looks clean:

if(EnumUtils.isValidEnum(Fruit.class, fruitname)) { ....

You will need to use the latest commons-lang3 library as commons-lang 2.x does not have this function.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)