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