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
10
11
12
13 public enum InstallationMode
14 {
15
16
17
18
19 REMOTE("remote"),
20
21
22
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 }