Fix string duplication in Ipv6Utils
[mdsal.git] / model / ietf / ietf-type-util / src / main / java / org / opendaylight / mdsal / model / ietf / util / Ipv6Utils.java
index 86fcb224da019c6947ae14494a85507a045b10a4..c5e94e829257385af5b9785dd6a64aaa36db9a21 100644 (file)
@@ -118,19 +118,23 @@ final class Ipv6Utils {
         }
 
         if (haveVal) {
-            verify(j + INT16SZ <= INADDR6SZ, "Overrun in parsing of '%s', should not occur", str);
+            verifySize(j + INT16SZ <= INADDR6SZ, str);
             bytes[j++] = (byte) (val >> 8 & 0xff);
             bytes[j++] = (byte) (val & 0xff);
         }
 
         if (colonp != -1) {
-            verify(j != INADDR6SZ, "Overrun in parsing of '%s', should not occur", str);
+            verifySize(j != INADDR6SZ, str);
             expandZeros(bytes, colonp, j);
         } else {
-            verify(j == INADDR6SZ, "Overrun in parsing of '%s', should not occur", str);
+            verifySize(j == INADDR6SZ, str);
         }
     }
 
+    private static void verifySize(final boolean expression, final String str) {
+        verify(expression, "Overrun in parsing of '%s', should not occur", str);
+    }
+
     private static void expandZeros(final byte[] bytes, final int where, final int filledBytes) {
         final int tailLength = filledBytes - where;
         final int tailOffset = INADDR6SZ - tailLength;