Apply modernization to PCEPHexDumpParser 02/84902/2
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 3 Oct 2019 14:52:13 +0000 (16:52 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 4 Oct 2019 09:41:45 +0000 (11:41 +0200)
- do not use Lists.newLinkedList()
- use StandardCharsets.UTF_8

Change-Id: I28d2b8468474c7e20c3d9bd5f3d8f95eee273624
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
util/src/main/java/org/opendaylight/protocol/util/PCEPHexDumpParser.java

index 26c3744a3582d227e36b1841e005b68bc3a641dd..0a0f20ea1842af237c08089107ebe83be28a10e5 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.protocol.util;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
 import com.google.common.io.BaseEncoding;
 import com.google.common.io.CharStreams;
 import java.io.File;
@@ -18,6 +17,8 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
 import org.slf4j.Logger;
@@ -43,8 +44,7 @@ public final class PCEPHexDumpParser {
     }
 
     public static List<byte[]> parseMessages(final InputStream is) throws IOException {
-        requireNonNull(is);
-        try (InputStreamReader isr = new InputStreamReader(is, "UTF-8")) {
+        try (InputStreamReader isr = new InputStreamReader(requireNonNull(is), StandardCharsets.UTF_8)) {
             return parseMessages(CharStreams.toString(isr));
         }
     }
@@ -52,7 +52,7 @@ public final class PCEPHexDumpParser {
     private static List<byte[]> parseMessages(final String msg) {
         final String content = clearWhiteSpaceToUpper(msg);
 
-        final List<byte[]> messages = Lists.newLinkedList();
+        final List<byte[]> messages = new LinkedList<>();
         int idx = content.indexOf(LENGTH, 0);
         while (idx > -1) {
             // next chars are final length, ending with '.'