X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=policy-agent%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fpolicyagent%2Frepository%2FPolicyTypes.java;h=2897a502ab436e2d2a915b2bdc5a3792b256ade3;hb=0316038265be758ae8b1bce006b5fd017185c55d;hp=0d66e7de0d9e43f184d8dda78d79e2928de10512;hpb=805681f9c4f555fd905af4ecd4f0beea8d657327;p=nonrtric.git diff --git a/policy-agent/src/main/java/org/oransc/policyagent/repository/PolicyTypes.java b/policy-agent/src/main/java/org/oransc/policyagent/repository/PolicyTypes.java index 0d66e7de..2897a502 100644 --- a/policy-agent/src/main/java/org/oransc/policyagent/repository/PolicyTypes.java +++ b/policy-agent/src/main/java/org/oransc/policyagent/repository/PolicyTypes.java @@ -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 types = new HashMap(); - - public PolicyTypes() { - } + private Map types = new HashMap<>(); public synchronized PolicyType getType(String name) throws ServiceException { PolicyType t = types.get(name); @@ -40,23 +38,27 @@ public class PolicyTypes { return t; } + public synchronized PolicyType get(String name) { + return types.get(name); + } + public synchronized void put(PolicyType type) { types.put(type.name(), type); } - public boolean contains(String policyType) { + public synchronized boolean contains(String policyType) { return types.containsKey(policyType); } public synchronized Collection 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(); } }