Add HexFormat FIXMEs 92/97592/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 21 Sep 2021 23:55:40 +0000 (01:55 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 21 Sep 2021 23:55:40 +0000 (01:55 +0200)
Add markers where we should be taking advantage of Java 17's new
HexFormat class.

Change-Id: I907502f7c976163ec44df62bf056df282ae9a743
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
model/ietf/ietf-type-util/src/main/java/org/opendaylight/mdsal/model/ietf/util/AbstractIetfYangUtil.java

index b0a3676bafed345b9fabe440e80704a4228f7305..aa0bcf4991f11db67d097017411b8075d5408f1e 100644 (file)
@@ -162,6 +162,7 @@ public abstract class AbstractIetfYangUtil<M, P, H, Q, U> {
 
     protected abstract String getQuadValue(Q dottedQuad);
 
+    // FIXME: Replace with HexFormat.fromHexDigit(ch) when we have JDK17+
     static byte hexValue(final char ch) {
         byte value;
         try {
@@ -212,6 +213,7 @@ public abstract class AbstractIetfYangUtil<M, P, H, Q, U> {
      * @throws NullPointerException if input is null
      * @throws IllegalArgumentException if length of input is not 6 bytes
      */
+    // TODO: HexFormat.ofDelimiter(":").withUpperCase().formatHex(bytes) when we have JDK17+? Compare performance
     private static @NonNull String bytesToString(final byte @NonNull[] bytes, final int charHint) {
         final StringBuilder sb = new StringBuilder(charHint);
         appendHexByte(sb, bytes[0]);
@@ -222,6 +224,7 @@ public abstract class AbstractIetfYangUtil<M, P, H, Q, U> {
         return sb.toString();
     }
 
+    // FIXME: Replace with HexFormat.toHexDigits(sb, byteVal) when we have JDK17+, but note we prefer capital letters
     private static void appendHexByte(final StringBuilder sb, final byte byteVal) {
         final int intVal = Byte.toUnsignedInt(byteVal);
         sb.append(HEX_CHARS[intVal >>> 4]).append(HEX_CHARS[intVal & 15]);