@Override public JsonValue encode(Number value) { String stringValue; if (value == null) { stringValue = getNullRepresentation(); } else if (formatString != null && locale != null) { stringValue = String.format(locale, formatString, value); } else if (numberFormat != null) { stringValue = numberFormat.format(value); } else { throw new IllegalStateException(String.format("Internal bug: " + "%s is in an illegal state: " + "[locale: %s, numberFormat: %s, formatString: %s]", getClass().getSimpleName(), locale, numberFormat, formatString)); } return encode(stringValue, String.class); }