Added SUSPENDED state and utility to get instance from String

This commit is contained in:
Luca Frosini 2024-11-12 17:03:33 +01:00
parent 36de5f8310
commit 4d0ffc8e4b
1 changed files with 23 additions and 0 deletions

View File

@ -1,11 +1,30 @@
package org.gcube.informationsystem.contexts.reference;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public enum ContextState {
CREATED("created"),
ACTIVE("active"),
SUSPENDED("suspended"),
DELETED("deleted");
private static final Map<String,ContextState> ENUM_MAP;
static {
ContextState[] array = ContextState.values();
Map<String,ContextState> map = new ConcurrentHashMap<>(array.length);
for (ContextState cs : array) {
map.put(cs.getState().toLowerCase(),cs);
}
ENUM_MAP = Collections.unmodifiableMap(map);
}
protected String state;
ContextState(String state) {
@ -15,5 +34,9 @@ public enum ContextState {
public String getState() {
return state;
}
public static ContextState fromString(String state) {
return ENUM_MAP.get(state.toLowerCase());
}
}