code: public static <T extends Enum> T getExtension(SlingHttpServletRequest request, T defaultValue) {
          String extension = request.getRequestPathInfo().getExtension();
          if (extension != null) {
              Class type = defaultValue.getClass();
              try {
                  T value = (T) T.valueOf(type, extension.toLowerCase());
                  return value;
              } catch (IllegalArgumentException iaex) {
                  // ok, use default
              }
          }
          return defaultValue;
      }
docs: Returns the enum value of the requests extension if appropriate otherwise the default value.
  
  @param request      the request object with the extension info
  @param defaultValue the default enum value
  @param <T>          the enum type derived from the default value