Policy 1707 commit to LF
[policy/engine.git] / PolicyEngineAPI / src / main / java / org / openecomp / policy / api / PolicyConfigType.java
index 111c856..7b3ca2f 100644 (file)
 
 package org.openecomp.policy.api;
 
+import com.fasterxml.jackson.annotation.JsonCreator;
+
 /**
  * Enumeration of the Policy Config Types that is used as a part of
  * {@link org.openecomp.policy.api.PolicyParameters}.
  * 
  * @version 0.1
  */
-public enum PolicyConfigType {
+public enum PolicyConfigType{
        /**
         * Indicates Base Config Policy. 
         */
@@ -59,8 +61,8 @@ public enum PolicyConfigType {
        
        private String name;
        
-       private PolicyConfigType(String typeName){
-               this.name = typeName;
+       private PolicyConfigType(String name){
+               this.name = name;
        }
        
        /**
@@ -68,6 +70,16 @@ public enum PolicyConfigType {
         * @return the <code>String</code> of the Type for this <code>PolicyClass</code>
         */
        public String toString() {
-               return this.name;
+               return name;
        }
+       
+       @JsonCreator
+    public static PolicyConfigType create (String value) {
+        for(PolicyConfigType type: values()){
+            if(type.toString().equals(value) || type.equals(PolicyConfigType.valueOf(value))){
+                return type;
+            }
+        }
+        throw new IllegalArgumentException();
+    }
 }