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=77982310022a3256b8c57cb335ae73186cf75e1a;hb=b66dcce5210e25b2571036becb6f0e7b0c23e1b2;hp=dc299b62c17486441ff70b45a93369507d23ab75;hpb=4a7dd457d5b179dd0f588663fc1476dacfca4f22;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 dc299b62..77982310 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 @@ -20,20 +20,15 @@ package org.oransc.policyagent.repository; +import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.Map; import org.oransc.policyagent.exceptions.ServiceException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class PolicyTypes { - private static final Logger logger = LoggerFactory.getLogger(PolicyTypes.class); - - 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); @@ -43,8 +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 synchronized boolean contains(String policyType) { + return types.containsKey(policyType); + } + + public synchronized Collection getAll() { + return Collections.unmodifiableCollection(types.values()); + } + + public synchronized int size() { + return types.size(); + } + + public synchronized void clear() { + this.types.clear(); + } }