UseEnumSwitch
Prefer using a switch instead of a chained if-else for enums

Severity
SUGGESTION

The problem

Consider using switch instead of if/else for enums. That is, prefer this:

switch (foo.getBar()) {
  case BAZ:
    doSomething();
    break;
  default:
    doSomethingElse();
}

instead of this:

if (foo.getBar().equals(Bar.BAZ)) {
  doSomething();
} else {
  doSomethingElse();
}

Switches on enums have a few small advantages worth considering:

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("UseEnumSwitch") to the enclosing element.