Initial source code
[oam/tr069-adapter.git] / acs / requestprocessor / src / main / java / org / commscope / tr069adapter / acs / requestprocessor / dto / SessionState.java
diff --git a/acs/requestprocessor/src/main/java/org/commscope/tr069adapter/acs/requestprocessor/dto/SessionState.java b/acs/requestprocessor/src/main/java/org/commscope/tr069adapter/acs/requestprocessor/dto/SessionState.java
new file mode 100644 (file)
index 0000000..50cb777
--- /dev/null
@@ -0,0 +1,52 @@
+/*\r
+ * ============LICENSE_START========================================================================\r
+ * ONAP : tr-069-adapter\r
+ * =================================================================================================\r
+ * Copyright (C) 2020 CommScope Inc Intellectual Property.\r
+ * =================================================================================================\r
+ * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,\r
+ * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You\r
+ * may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\r
+ * either express or implied. See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ===============LICENSE_END=======================================================================\r
+ */\r
+\r
+package org.commscope.tr069adapter.acs.requestprocessor.dto;\r
+\r
+import java.util.EnumSet;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+public enum SessionState {\r
+\r
+  READY(0), PROCESSING(1), LOCKED(2), TERMINATED(3);\r
+\r
+  private Integer value;\r
+\r
+  private SessionState(Integer operationCode) {\r
+    this.value = operationCode;\r
+  }\r
+\r
+  // Lookup tables\r
+  private static final Map<Integer, SessionState> reverselookup = new HashMap<>();\r
+\r
+  // Populate the lookup tables on loading time\r
+  static {\r
+    for (SessionState state : EnumSet.allOf(SessionState.class)) {\r
+      reverselookup.put(state.getValue(), state);\r
+    }\r
+  }\r
+\r
+  public static SessionState getByValue(Integer value) {\r
+    return reverselookup.get(value);\r
+  }\r
+\r
+  public Integer getValue() {\r
+    return value;\r
+  }\r
+}\r