https://bz.apache.org/bugzilla/show_bug.cgi?id=67080

--- Comment #14 from Christopher Schultz <ch...@christopherschultz.net> ---
The fromLookupAndSwitch technique seems to be implemented in an awkward way.
Why bother converting from String -> Enum and then using a switch on the enum,
instead of just (a) implementing a getScopeNumber() method in each enum
instance or (b) just using convenient ordinal values which match the value you
actually want?

I would think this would be the best implementation if you wanted to use Enums:

enum Scope {
    applicationScope(0), cookie(1), header(2), ...

  public static int fromLookupAndSwitch(String scope) {
    Scope scope = lookupMap.get(scope);
    if(null == scope) {
    } else {
      return scope.ordinal();
    }
  }
}

I understand that this test is no longer "from lookup and switch" but I decided
to keep the method name the same.

I guess the point is if you use a hash, you don't have to use a switch at all.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to