Reverts NumberRenderer and StringRenderer to accept Object instead of Number or String respectively.
NumberRenderer always worked with Object before.
Actually it should be called FormatRenderer or similar because it merely uses Formatter, nothing Number-specific.
StringRenderer now uses the pre-#233 behaviour of accepting Object at runtime, but failing if the actual value is not a String due to the forced cast.
The main motivation is that #233 broke code like this:
class CustomStringRenderer extends StringRenderer {
@Override
public String toString(Object value, String formatString, Locale locale) {
if ("decap".equals(formatString)) { return ... };
return super.toString(value, formatString, locale);
}
}
Now suddenly that method no longer overrides toString from StringRenderer, because it had the signature toString(String, String, Locale) in #233. And now we have breaking changes!
Reverts NumberRenderer and StringRenderer to accept Object instead of Number or String respectively.
NumberRenderer always worked with Object before. Actually it should be called FormatRenderer or similar because it merely uses Formatter, nothing Number-specific.
StringRenderer now uses the pre-#233 behaviour of accepting Object at runtime, but failing if the actual value is not a String due to the forced cast.
The main motivation is that #233 broke code like this:
Now suddenly that method no longer overrides
toString
fromStringRenderer
, because it had the signaturetoString(
String
, String, Locale)
in #233. And now we have breaking changes!See https://github.com/Clashsoft/GenTreeSrc/blob/master/src/main/java/de/clashsoft/gentreesrc/codegen/StringRenderer.java for an example of this in the wild.