1 package com.atlassian.plugin;
2
3 import com.google.common.base.Strings;
4 import org.slf4j.Logger;
5 import org.slf4j.LoggerFactory;
6
7 import java.util.Optional;
8
9
10
11
12
13
14 public enum InstallationMode {
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 InstallationMode(String key) {
31 this.key = key;
32 }
33
34 public String getKey() {
35 return key;
36 }
37
38 public static Optional<InstallationMode> of(String name) {
39 for (InstallationMode mode : values()) {
40 if (mode.getKey().equalsIgnoreCase(name)) {
41 return Optional.of(mode);
42 }
43 }
44
45 if (!Strings.isNullOrEmpty(name)) {
46 LOGGER.warn("Could not match installation mode '{}' to any of existing {}. Ignoring.", name, values());
47 }
48
49 return Optional.empty();
50 }
51 }