0

I have a enum declared in a sepearate class :

public enum TypeEnum {
  BUSY, RELAX;
}

I need to use it in Junit Test case class:

 public void adValues(List<String> customAttributes) {
        switch (customAttributes.get(0).toString()) { //This return either BUSY or RELAX
          case "BUSY": //I need to use Enum's here now
          case "RELAX":
           .....
           .....

I tried something like this:

TypeEnum[] ttEnum = TypeEnum.values();
    for (TypeEnum val : ttEnum) {
    switch (customAttributes.get(0).toString()) {
      case ttEnum.BUSY: //BUSY cannot be resolved or is not a field
      case RELAX: //Compile time error:RELAX cannot be resolved to a variable
      ....

But it is giving me compile time error, I tried some other ways too, not no success.

Is there anyway to use switch case here or I should use if-else statement here.?

CoderBeginner
  • 717
  • 1
  • 12
  • 39

0 Answers0