Initial source code
[oam/tr069-adapter.git] / acs / common / src / main / java / org / commscope / tr069adapter / acs / common / dto / TR069OperationCode.java
diff --git a/acs/common/src/main/java/org/commscope/tr069adapter/acs/common/dto/TR069OperationCode.java b/acs/common/src/main/java/org/commscope/tr069adapter/acs/common/dto/TR069OperationCode.java
new file mode 100644 (file)
index 0000000..0888809
--- /dev/null
@@ -0,0 +1,57 @@
+/*\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 TR069OperationCode implements OperationCode {\r
+\r
+  GET_RPC_METHODS(100), SET_PARAMETER_VALUES(101), GET_PARAMETER_VALUES(102), GET_PARAMETER_NAMES(\r
+      103), SET_PARAMETER_ATTRIBUTES(104), GET_PARAMETER_ATTRIBUTES(105), ADD_OBJECT(\r
+          106), DELETE_OBJECT(107), REBOOT(108), DOWNLOAD(\r
+              109), SCHEDULE_DOWNLOAD(110), UPLOAD(111), FACTORY_RESET(112), INITIATE_CR(120);\r
+\r
+  private Integer operationCode;\r
+\r
+  private TR069OperationCode(Integer operationCode) {\r
+    this.operationCode = operationCode;\r
+  }\r
+\r
+  // Lookup tables\r
+  private static final Map<Integer, TR069OperationCode> reverselookup = new HashMap<>();\r
+\r
+  // Populate the lookup tables on loading time\r
+  static {\r
+    for (TR069OperationCode opCode : EnumSet.allOf(TR069OperationCode.class)) {\r
+      reverselookup.put(opCode.getOperationCode(), opCode);\r
+    }\r
+  }\r
+\r
+  public static TR069OperationCode getByOperationCode(Integer operationCode) {\r
+    return reverselookup.get(operationCode);\r
+  }\r
+\r
+  public Integer getOperationCode() {\r
+    return operationCode;\r
+  }\r
+}\r