summaryrefslogtreecommitdiffstats
path: root/pf4j/src
diff options
context:
space:
mode:
authorMacTrophy <macworld@sympatico.ca>2019-07-02 16:39:33 -0400
committerDecebal Suiu <decebal.suiu@gmail.com>2019-07-02 23:39:33 +0300
commit9ef232d34d7e75081571330bfc6ce0d2382d2bf7 (patch)
tree04e4c5905a84cf62bf26903c20a45ccb58dbb3a3 /pf4j/src
parent36995ea486bdcf720f9403c05dbe6c84c3dbb1fa (diff)
downloadpf4j-9ef232d34d7e75081571330bfc6ce0d2382d2bf7.tar.gz
pf4j-9ef232d34d7e75081571330bfc6ce0d2382d2bf7.zip
Modified org.pf4j.PluginState to an enum (#328)
Diffstat (limited to 'pf4j/src')
-rw-r--r--pf4j/src/main/java/org/pf4j/PluginState.java40
1 files changed, 19 insertions, 21 deletions
diff --git a/pf4j/src/main/java/org/pf4j/PluginState.java b/pf4j/src/main/java/org/pf4j/PluginState.java
index 51c3f48..7b5037a 100644
--- a/pf4j/src/main/java/org/pf4j/PluginState.java
+++ b/pf4j/src/main/java/org/pf4j/PluginState.java
@@ -18,33 +18,33 @@ package org.pf4j;
/**
* @author Decebal Suiu
*/
-public class PluginState {
+public enum PluginState {
/**
* The runtime knows the plugin is there. It knows about the plugin path, the plugin descriptor.
*/
- public static final PluginState CREATED = new PluginState("CREATED");
-
+ CREATED("CREATED"),
+
/**
* The plugin cannot be used.
*/
- public static final PluginState DISABLED = new PluginState("DISABLED");
-
+ DISABLED("DISABLED"),
+
/**
* The plugin is created. All the dependencies are created and resolved.
* The plugin is ready to be started.
*/
- public static final PluginState RESOLVED = new PluginState("RESOLVED");
+ RESOLVED("RESOLVED"),
/**
* The {@link Plugin#start()} has executed. A started plugin may contribute extensions.
*/
- public static final PluginState STARTED = new PluginState("STARTED");
+ STARTED("STARTED"),
/**
* The {@link Plugin#stop()} has executed.
*/
- public static final PluginState STOPPED = new PluginState("STOPPED");
+ STOPPED("STOPPED");
private String status;
@@ -52,19 +52,8 @@ public class PluginState {
this.status = status;
}
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- PluginState that = (PluginState) o;
-
- return status.equals(that.status);
- }
-
- @Override
- public int hashCode() {
- return status.hashCode();
+ public boolean equals(String status) {
+ return (status == null ? false : this.status.equalsIgnoreCase(status));
}
@Override
@@ -72,4 +61,13 @@ public class PluginState {
return status;
}
+ public static PluginState parse(String string) {
+ for (PluginState status : values()) {
+ if (status.equals(string)) {
+ return status;
+ }
+ }
+
+ return null;
+ }
}