View Javadoc

1   package com.atlassian.plugin;
2   
3   import com.atlassian.fugue.Option;
4   import org.apache.commons.lang.StringUtils;
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      /**
16       * Denotes a plugin installed from a remote plugin. This is the _proxy_ plugin created to represent and make the link
17       * with the remote plugin.
18       */
19      REMOTE("remote"),
20  
21      /**
22       * Denotes a plugin installed locally to the host application. This is the standard mode for plugins up to version 2.
23       */
24      LOCAL("local");
25  
26      private static final Logger LOGGER = LoggerFactory.getLogger(InstallationMode.class);
27  
28      private final String key;
29  
30      private InstallationMode(String key)
31      {
32          this.key = key;
33      }
34  
35      public String getKey()
36      {
37          return key;
38      }
39  
40      public static Option<InstallationMode> of(String name)
41      {
42          for (InstallationMode mode : values())
43          {
44              if (mode.getKey().equalsIgnoreCase(name))
45              {
46                  return Option.some(mode);
47              }
48          }
49  
50          if (StringUtils.isNotBlank(name))
51          {
52              LOGGER.warn("Could not match installation mode '{}' to any of existing {}. Ignoring.", name, values());
53          }
54  
55          return Option.none();
56      }
57  }