import java.util.Collection;
import java.util.HashSet;
+import java.util.Set;
import org.onap.policy.api.LoadedPolicy;
import org.onap.policy.api.NotificationType;
import org.onap.policy.api.PDPNotification;
import org.onap.policy.api.RemovedPolicy;
-import org.onap.policy.std.StdLoadedPolicy;
-import org.onap.policy.std.StdPDPNotification;
-import org.onap.policy.std.StdRemovedPolicy;
-
-import org.onap.policy.common.logging.flexlogger.*;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
public class MatchStore {
private static HashSet<Matches> matchStore = new HashSet<>();
private static Logger logger = FlexLogger.getLogger(MatchStore.class.getName());
- public static HashSet<Matches> getMatchStore() {
+ private MatchStore() {
+ // Empty Constructor
+ }
+
+ public static Set<Matches> getMatchStore() {
return matchStore;
}
}
// IF not a match then add it to the MatchStore
- if(match==false){
+ if(! match){
matchStore.add(newMatch);
}
}
//Logic changes for Requested Policies notifications..
public static PDPNotification checkMatch(PDPNotification oldNotification) {
- boolean removed = false, updated = false;
+ boolean removed = false;
+ boolean updated = false;
if(oldNotification==null){
return null;
}
StdPDPNotification newNotification = new StdPDPNotification();
if(matchStore.isEmpty()) {
logger.debug("No Success Config Calls made yet.. ");
- System.out.println("No success Config calls made yet. ");
return null;
}
if(oldNotification.getRemovedPolicies()!=null && !oldNotification.getRemovedPolicies().isEmpty()){
for(LoadedPolicy updatedPolicy: oldNotification.getLoadedPolicies()){
// if it is config policies check their matches..
if(updatedPolicy.getMatches()!=null && !updatedPolicy.getMatches().isEmpty()){
- boolean matched = false;
+ boolean matched;
for(Matches match : matchStore){
matched = false;
// Again Better way would be comparing sizes first.
// Comparing both the values..
boolean matchAttributes = false;
for(String newKey: updatedPolicy.getMatches().keySet()){
- if(newKey.equals("ONAPName")){
+ if("ONAPName".equals(newKey)){
if(updatedPolicy.getMatches().get(newKey).equals(match.getOnapName())){
matchAttributes = true;
}else {
matchAttributes = false;
break;
}
- }else if(newKey.equals("ConfigName")) {
+ }else if("ConfigName".equals(newKey)) {
if(updatedPolicy.getMatches().get(newKey).equals(match.getConfigName())){
matchAttributes = true;
}else{