Replace Guava's ImmutableList by java.util.List 81/106481/5
authorIvan Hrasko <ivan.hrasko@pantheon.tech>
Wed, 14 Jun 2023 12:24:31 +0000 (14:24 +0200)
committerIvan Hrasko <ivan.hrasko@pantheon.tech>
Thu, 15 Jun 2023 15:58:48 +0000 (15:58 +0000)
Use java.util.List.of/copyOf instead of Guava's ImmutableList.of/copyOf
in RestconfDocumentedException class.

Change-Id: I7a7abe0e56f5b06becfa4bbe8099025b11fb4d8b
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
restconf/restconf-common/src/main/java/org/opendaylight/restconf/common/errors/RestconfDocumentedException.java

index e0431f12b4534e5ed6fd532e4a3e5c6b3f8e7d2f..642613cc02e1ae8bedf4d41edb433b13d7d1c364 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.restconf.common.errors;
 
 import static java.util.Objects.requireNonNull;
 
-import com.google.common.collect.ImmutableList;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -37,9 +36,9 @@ import org.opendaylight.yangtools.yang.data.api.YangNetconfErrorAware;
  * @author Thomas Pantelis
  */
 public class RestconfDocumentedException extends WebApplicationException {
-    private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 2L;
 
-    private final ImmutableList<RestconfError> errors;
+    private final List<RestconfError> errors;
     private final Status status;
 
     /**
@@ -130,10 +129,9 @@ public class RestconfDocumentedException extends WebApplicationException {
         // this was lost also in original code.
         super(cause);
         if (!errors.isEmpty()) {
-            this.errors = ImmutableList.copyOf(errors);
+            this.errors = List.copyOf(errors);
         } else {
-            this.errors = ImmutableList.of(
-                new RestconfError(ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, message));
+            this.errors = List.of(new RestconfError(ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, message));
         }
 
         status = null;
@@ -154,19 +152,19 @@ public class RestconfDocumentedException extends WebApplicationException {
      *            the HTTP status.
      */
     public RestconfDocumentedException(final Status status) {
-        errors = ImmutableList.of();
+        errors = List.of();
         this.status = requireNonNull(status, "Status can't be null");
     }
 
     public RestconfDocumentedException(final Throwable cause, final RestconfError error) {
         super(cause, ErrorTags.statusOf(error.getErrorTag()));
-        errors = ImmutableList.of(error);
+        errors = List.of(error);
         status = null;
     }
 
     public RestconfDocumentedException(final Throwable cause, final List<RestconfError> errors) {
         super(cause, ErrorTags.statusOf(errors.get(0).getErrorTag()));
-        this.errors = ImmutableList.copyOf(errors);
+        this.errors = List.copyOf(errors);
         status = null;
     }
 
@@ -246,7 +244,7 @@ public class RestconfDocumentedException extends WebApplicationException {
                 .map(error -> new RestconfError(error.type(), error.tag(), error.message(), error.appTag(),
                     // FIXME: pass down error info
                     null, error.path()))
-                .collect(ImmutableList.toImmutableList()));
+                .toList());
         }
     }