View Javadoc
1   package com.atlassian.plugin;
2   
3   import com.atlassian.fugue.Option;
4   import com.google.common.base.Strings;
5   import org.slf4j.Logger;
6   import org.slf4j.LoggerFactory;
7   
8   /**
9    * The mode of installation of a plugin
10   *
11   * @since 3.0
12   */
13  public enum InstallationMode {
14      /**
15       * Denotes a plugin installed from a remote plugin. This is the _proxy_ plugin created to represent and make the link
16       * with the remote plugin.
17       */
18      REMOTE("remote"),
19  
20      /**
21       * Denotes a plugin installed locally to the host application. This is the standard mode for plugins up to version 2.
22       */
23      LOCAL("local");
24  
25      private static final Logger LOGGER = LoggerFactory.getLogger(InstallationMode.class);
26  
27      private final String key;
28  
29      private InstallationMode(String key) {
30          this.key = key;
31      }
32  
33      public String getKey() {
34          return key;
35      }
36  
37      public static Option<InstallationMode> of(String name) {
38          for (InstallationMode mode : values()) {
39              if (mode.getKey().equalsIgnoreCase(name)) {
40                  return Option.some(mode);
41              }
42          }
43  
44          if (!Strings.isNullOrEmpty(name)) {
45              LOGGER.warn("Could not match installation mode '{}' to any of existing {}. Ignoring.", name, values());
46          }
47  
48          return Option.none();
49      }
50  }