Remove code smells in dashboard
[nonrtric.git] / dashboard / webapp-backend / src / main / java / org / oransc / ric / portal / dashboard / policyagentapi / PolicyAgentApiImpl.java
index 470e2df..f01137e 100644 (file)
@@ -28,10 +28,10 @@ import com.google.gson.reflect.TypeToken;
 
 import java.lang.invoke.MethodHandles;
 import java.lang.reflect.Type;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
-import java.util.Vector;
 
 import org.immutables.gson.Gson;
 import org.immutables.value.Value;
@@ -58,14 +58,14 @@ public class PolicyAgentApiImpl implements PolicyAgentApi {
     RestTemplate restTemplate = new RestTemplate();
 
     private static com.google.gson.Gson gson = new GsonBuilder() //
-            .serializeNulls() //
-            .create(); //
+        .serializeNulls() //
+        .create(); //
 
     private final String urlPrefix;
 
     @Autowired
     public PolicyAgentApiImpl(
-            @org.springframework.beans.factory.annotation.Value("${policycontroller.url.prefix}") final String urlPrefix) {
+        @org.springframework.beans.factory.annotation.Value("${policycontroller.url.prefix}") final String urlPrefix) {
         logger.debug("ctor prefix '{}'", urlPrefix);
         this.urlPrefix = urlPrefix;
     }
@@ -119,8 +119,7 @@ public class PolicyAgentApiImpl implements PolicyAgentApi {
         }
 
         try {
-            Type listType = new TypeToken<List<ImmutablePolicyInfo>>() {
-            }.getType();
+            Type listType = new TypeToken<List<ImmutablePolicyInfo>>() {}.getType();
             List<PolicyInfo> rspParsed = gson.fromJson(rsp.getBody(), listType);
             PolicyInstances result = new PolicyInstances();
             for (PolicyInfo p : rspParsed) {
@@ -142,13 +141,13 @@ public class PolicyAgentApiImpl implements PolicyAgentApi {
 
     @Override
     public ResponseEntity<String> putPolicy(String policyTypeIdString, String policyInstanceId, Object json,
-            String ric) {
+        String ric) {
         String url = baseUrl() + "/policy?type={type}&instance={instance}&ric={ric}&service={service}";
         Map<String, ?> uriVariables = Map.of( //
-                "type", policyTypeIdString, //
-                "instance", policyInstanceId, //
-                "ric", ric, //
-                "service", "dashboard");
+            "type", policyTypeIdString, //
+            "instance", policyInstanceId, //
+            "ric", ric, //
+            "service", "dashboard");
 
         try {
             this.restTemplate.put(url, createJsonHttpEntity(json), uriVariables);
@@ -188,10 +187,9 @@ public class PolicyAgentApiImpl implements PolicyAgentApi {
         String rsp = this.restTemplate.getForObject(url, String.class, uriVariables);
 
         try {
-            Type listType = new TypeToken<List<ImmutableRicInfo>>() {
-            }.getType();
+            Type listType = new TypeToken<List<ImmutableRicInfo>>() {}.getType();
             List<RicInfo> rspParsed = gson.fromJson(rsp, listType);
-            Collection<String> result = new Vector<>(rspParsed.size());
+            Collection<String> result = new ArrayList<>(rspParsed.size());
             for (RicInfo ric : rspParsed) {
                 result.add(ric.ricName());
             }
@@ -204,7 +202,7 @@ public class PolicyAgentApiImpl implements PolicyAgentApi {
     private HttpEntity<Object> createJsonHttpEntity(Object content) {
         HttpHeaders headers = new HttpHeaders();
         headers.setContentType(MediaType.APPLICATION_JSON);
-        return new HttpEntity<Object>(content, headers);
+        return new HttpEntity<>(content, headers);
     }
 
 }