code: public static <T extends Enum> T getSelector(SlingHttpServletRequest request, T defaultValue) {
          String[] selectors = request.getRequestPathInfo().getSelectors();
          Class type = defaultValue.getClass();
          for (String selector : selectors) {
              try {
                  T value = (T) T.valueOf(type, selector);
                  return value;
              } catch (IllegalArgumentException iaex) {
                  // ok, try next
              }
          }
          return defaultValue;
      }
docs: Returns an enum value from selectors if an appropriate selector
  can be found otherwise the default value given.
  
  @param request      the request object with the selector info
  @param defaultValue the default enum value
  @param <T>          the enum type derived from the default value