Merge "Added RIC state to RicInfo in the agent NBI"
[nonrtric.git] / policy-agent / src / main / java / org / oransc / policyagent / repository / PolicyTypes.java
index 9dee6f9..2897a50 100644 (file)
@@ -23,14 +23,12 @@ 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;
 
 public class PolicyTypes {
-    private Map<String, PolicyType> types = new HashMap<String, PolicyType>();
-
-    public PolicyTypes() {
-    }
+    private Map<String, PolicyType> types = new HashMap<>();
 
     public synchronized PolicyType getType(String name) throws ServiceException {
         PolicyType t = types.get(name);
@@ -48,19 +46,19 @@ public class PolicyTypes {
         types.put(type.name(), type);
     }
 
-    public boolean contains(String policyType) {
+    public synchronized boolean contains(String policyType) {
         return types.containsKey(policyType);
     }
 
     public synchronized Collection<PolicyType> getAll() {
-        return types.values();
+        return new Vector<>(types.values());
     }
 
-    public int size() {
+    public synchronized int size() {
         return types.size();
     }
 
-    public void clear() {
+    public synchronized void clear() {
         this.types.clear();
     }
 }