Remove code smells in Policy Agent
[nonrtric.git] / policy-agent / src / main / java / org / oransc / policyagent / repository / Ric.java
index 6eece5e..c50a0f0 100644 (file)
 
 package org.oransc.policyagent.repository;
 
-import java.util.ArrayList;
+import com.google.common.collect.ImmutableList;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.Vector;
+
 import lombok.Getter;
 import lombok.Setter;
+
 import org.oransc.policyagent.clients.A1Client.A1ProtocolType;
 import org.oransc.policyagent.configuration.RicConfig;
 
@@ -35,8 +36,9 @@ import org.oransc.policyagent.configuration.RicConfig;
  * Represents the dynamic information about a NearRealtime-RIC.
  */
 public class Ric {
+
     private final RicConfig ricConfig;
-    private final List<String> managedElementIds;
+    private final ImmutableList<String> managedElementIds;
 
     private RicState state = RicState.UNDEFINED;
     private Map<String, PolicyType> supportedPolicyTypes = new HashMap<>();
@@ -44,15 +46,17 @@ public class Ric {
     @Setter
     private A1ProtocolType protocolVersion = A1ProtocolType.UNKNOWN;
 
+    @Getter
+    private final Lock lock = new Lock();
 
     /**
-     * Creates the Ric. Initial state is {@link RicState.NOT_INITIATED}.
+     * Creates the Ric. Initial state is {@link RicState.UNDEFINED}.
      *
      * @param ricConfig The {@link RicConfig} for this Ric.
      */
     public Ric(RicConfig ricConfig) {
         this.ricConfig = ricConfig;
-        this.managedElementIds = new ArrayList<>(ricConfig.managedElementIds());
+        this.managedElementIds = ricConfig.managedElementIds();
     }
 
     public String name() {
@@ -90,26 +94,6 @@ public class Ric {
         return managedElementIds.contains(managedElementId);
     }
 
-    /**
-     * Adds the given node as managed by this Ric.
-     *
-     * @param managedElementId the node to add.
-     */
-    public synchronized void addManagedElement(String managedElementId) {
-        if (!managedElementIds.contains(managedElementId)) {
-            managedElementIds.add(managedElementId);
-        }
-    }
-
-    /**
-     * Removes the given node as managed by this Ric.
-     *
-     * @param managedElementId the node to remove.
-     */
-    public synchronized void removeManagedElement(String managedElementId) {
-        managedElementIds.remove(managedElementId);
-    }
-
     /**
      * Gets the policy types supported by this Ric.
      *