View Javadoc

1   package com.atlassian.johnson.event;
2   
3   import javax.annotation.Nullable;
4   
5   import static com.atlassian.johnson.event.EventLevel.ERROR;
6   import static com.atlassian.johnson.event.EventLevel.FATAL;
7   import static com.atlassian.johnson.event.EventLevel.WARNING;
8   import static com.atlassian.johnson.event.EventLevel.get;
9   
10  /**
11   * Commonly-used {@link EventLevel}s. This is more typesafe than using the Strings in that class.
12   *
13   * This is not an enum because the levels can't be loaded until Johnson is initialised.
14   *
15   * @since 3.2
16   */
17  public final class EventLevels {
18  
19      /**
20       * Returns the {@link EventLevel#FATAL} event level.
21       *
22       * @return null if no such level is defined
23       * @throws IllegalStateException if Johnson has not been initialised
24       * @since 3.2
25       */
26      @Nullable
27      public static EventLevel fatal() {
28          return get(FATAL);
29      }
30  
31      /**
32       * Returns the {@link EventLevel#ERROR} event level.
33       *
34       * @return null if no such level is defined
35       * @throws IllegalStateException if Johnson has not been initialised
36       * @since 3.2
37       */
38      @Nullable
39      public static EventLevel error() {
40          return get(ERROR);
41      }
42  
43      /**
44       * Returns the {@link EventLevel#WARNING} event level.
45       *
46       * @return null if no such level is defined
47       * @throws IllegalStateException if Johnson has not been initialised
48       * @since 3.2
49       */
50      @Nullable
51      public static EventLevel warning() {
52          return get(WARNING);
53      }
54  
55      private EventLevels() {}
56  }