Inline INCORRECT_LEXICAL_REPRESENTATION 74/86574/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 25 Dec 2019 22:11:21 +0000 (23:11 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 25 Dec 2019 22:13:34 +0000 (23:13 +0100)
This inlines the string used from a single place, eliminating
the need for String.format() and thus fixing a SpotBugs
VA_FORMAT_STRING_USES_NEWLINE issue.

Change-Id: I0746b4b28cce4ff991a632ab38ad8499e5f9aadf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/codec/AbstractIntegerStringCodec.java

index a6afa2d51013d8c0f3237812dee4efbd32e83789..24b49b7fe10b42ca3d0cfe5720ae3b7a799dcce3 100644 (file)
@@ -46,14 +46,6 @@ public abstract class AbstractIntegerStringCodec<N extends Number & Comparable<N
     // For up to two characters, this is very fast
     private static final CharMatcher X_MATCHER = CharMatcher.anyOf("xX");
 
-    // FIXME: inline this
-    private static final String INCORRECT_LEXICAL_REPRESENTATION =
-            "Incorrect lexical representation of integer value: %s."
-                    + "\nAn integer value can be defined as: "
-                    + "\n  - a decimal number,"
-                    + "\n  - a hexadecimal number (prefix 0x)," + "%n  - an octal number (prefix 0)."
-                    + "\nSigned values are allowed. Spaces between digits are NOT allowed.";
-
     private final RangeSet<N> rangeConstraints;
 
     AbstractIntegerStringCodec(final T typeDefinition, final Optional<RangeConstraint<N>> constraint,
@@ -140,7 +132,11 @@ public abstract class AbstractIntegerStringCodec<N extends Number & Comparable<N
         } else if (OCT_PATTERN.matcher(integer).matches()) {
             return 8;
         } else {
-            throw new NumberFormatException(String.format(INCORRECT_LEXICAL_REPRESENTATION, integer));
+            throw new NumberFormatException("Incorrect lexical representation of integer value: " + integer + ".\n"
+                        + "An integer value can be defined as:\n"
+                        + "  - a decimal number,\n"
+                        + "  - a hexadecimal number (prefix 0x)," + "%n  - an octal number (prefix 0).\n"
+                        + "Signed values are allowed. Spaces between digits are NOT allowed.");
         }
     }
 }