View Javadoc
1   package com.atlassian.plugin.servlet.filter;
2   
3   import javax.servlet.DispatcherType;
4   
5   /**
6    * The dispatching conditions that are taken into account when deciding to match a filter. These match to the dispatcher
7    * values allowed in the Servlet API version 2.4.
8    *
9    * @since 2.5.0
10   * @deprecated since 4.6.0. Use {@link javax.servlet.DispatcherType} instead.
11   */
12  @Deprecated
13  public enum FilterDispatcherCondition {
14      REQUEST(DispatcherType.REQUEST),
15      INCLUDE(DispatcherType.INCLUDE),
16      FORWARD(DispatcherType.FORWARD),
17      ERROR(DispatcherType.ERROR),
18      /**
19       * @since 4.6.0
20       */
21      ASYNC(DispatcherType.ASYNC);
22  
23      private final DispatcherType dispatcherType;
24  
25      FilterDispatcherCondition(DispatcherType dispatcherType) {
26          this.dispatcherType = dispatcherType;
27      }
28  
29      /**
30       * Determines if a dispatcher value is a valid condition
31       *
32       * @param dispatcher The dispatcher value. Null allowed.
33       * @return True if valid, false otherwise
34       */
35      public static boolean contains(String dispatcher) {
36          for (FilterDispatcherCondition cond : values()) {
37              if (cond.toString().equals(dispatcher)) {
38                  return true;
39              }
40          }
41          return false;
42      }
43  
44      /**
45       * @since 4.6.0
46       */
47      public DispatcherType toDispatcherType() {
48          return dispatcherType;
49      }
50  
51      /**
52       * @since 4.6.0
53       */
54      public static FilterDispatcherCondition fromDispatcherType(DispatcherType dispatcherType) {
55          for (FilterDispatcherCondition cond : values()) {
56              if (cond.toDispatcherType().equals(dispatcherType)) {
57                  return cond;
58              }
59          }
60          return null;
61      }
62  }