Merge "Added STD sim 2.0.0 tests"
[nonrtric.git] / policy-agent / src / main / java / org / oransc / policyagent / repository / PolicyTypes.java
index 47b815b..2897a50 100644 (file)
 
 package org.oransc.policyagent.repository;
 
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Vector;
 
 import org.oransc.policyagent.exceptions.ServiceException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
 
-@Component
 public class PolicyTypes {
-    private static final Logger logger = LoggerFactory.getLogger(PolicyTypes.class);
-
-    private Map<String, PolicyType> types = new HashMap<String, PolicyType>();
-
-    @Autowired
-    public PolicyTypes() {
-    }
+    private Map<String, PolicyType> types = new HashMap<>();
 
     public synchronized PolicyType getType(String name) throws ServiceException {
         PolicyType t = types.get(name);
@@ -47,8 +38,27 @@ public class PolicyTypes {
         return t;
     }
 
-    public synchronized void putType(String name, PolicyType type) {
-        types.put(name, type);
+    public synchronized PolicyType get(String name) {
+        return types.get(name);
+    }
+
+    public synchronized void put(PolicyType type) {
+        types.put(type.name(), type);
+    }
+
+    public synchronized boolean contains(String policyType) {
+        return types.containsKey(policyType);
+    }
+
+    public synchronized Collection<PolicyType> getAll() {
+        return new Vector<>(types.values());
     }
 
+    public synchronized int size() {
+        return types.size();
+    }
+
+    public synchronized void clear() {
+        this.types.clear();
+    }
 }