@@ -223,8 +223,7 @@ private static String formatNumber(final Number value, final Display display,
223223 }
224224 if (option == FormatOption .HEX )
225225 {
226- final StringBuilder buf = new StringBuilder ();
227- Optional <Long > maybeLongValue ;
226+ final Optional <Long > maybeLongValue ;
228227 if (value instanceof Byte valueByte ) {
229228 maybeLongValue = Optional .of (Byte .toUnsignedLong (valueByte ));
230229 } else if (value instanceof Short valueShort ) {
@@ -248,17 +247,18 @@ private static String formatNumber(final Number value, final Display display,
248247 } else {
249248 maybeLongValue = Optional .empty ();
250249 }
251-
250+
252251 if (maybeLongValue .isPresent ()) {
253252 long longValue = maybeLongValue .get ();
254- String hexString = Long .toHexString (longValue );
253+ final String hexString = Long .toHexString (longValue );
254+ final StringBuilder buf = new StringBuilder ();
255255 buf .append (hexString .toUpperCase ());
256256 for (int i =buf .length (); i <precision ; ++i )
257257 buf .insert (0 , '0' );
258258 buf .insert (0 , "0x" );
259259 return buf .toString ();
260260 } else {
261- String numberFormat = value .getClass ().getSimpleName ();
261+ final String numberFormat = value .getClass ().getSimpleName ();
262262 Logger .getLogger (FormatOptionHandler .class .getPackageName ())
263263 .log (Level .WARNING , "Error: Number format is unsupported for conversion to HEX format: " + numberFormat );
264264 return "ERROR: Unsupported number format: " + numberFormat ;
0 commit comments