Initial source code
[oam/tr069-adapter.git] / acs / common / src / main / java / org / commscope / tr069adapter / acs / common / dto / CustomOperationCode.java
diff --git a/acs/common/src/main/java/org/commscope/tr069adapter/acs/common/dto/CustomOperationCode.java b/acs/common/src/main/java/org/commscope/tr069adapter/acs/common/dto/CustomOperationCode.java
new file mode 100644 (file)
index 0000000..1108c17
--- /dev/null
@@ -0,0 +1,61 @@
+/*\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.common.dto;\r
+\r
+import java.util.EnumSet;\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import org.commscope.tr069adapter.acs.common.OperationCode;\r
+\r
+public enum CustomOperationCode implements OperationCode {\r
+\r
+  CONFIGURE_MULTIPLE_OBJECTS(200, "ConfigureMultipleObject"), CONNECT(201,\r
+      "CheckDeviceAvailability");\r
+\r
+  private Integer operationCode;\r
+  private String jndiName;\r
+\r
+  private CustomOperationCode(Integer operationCode, String jndiName) {\r
+    this.operationCode = operationCode;\r
+    this.jndiName = jndiName;\r
+  }\r
+\r
+  public Integer getOperationCode() {\r
+    return operationCode;\r
+  }\r
+\r
+  public String getJndiName() {\r
+    return jndiName;\r
+  }\r
+\r
+  // Lookup tables\r
+  private static final Map<Integer, CustomOperationCode> reverselookup = new HashMap<>();\r
+\r
+  // Populate the lookup tables on loading time\r
+  static {\r
+    for (CustomOperationCode opCode : EnumSet.allOf(CustomOperationCode.class)) {\r
+      reverselookup.put(opCode.getOperationCode(), opCode);\r
+    }\r
+  }\r
+\r
+  public static CustomOperationCode getByOperationCode(Integer operationCode) {\r
+    return reverselookup.get(operationCode);\r
+  }\r
+}\r