You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AttributeRenderer classes like DateRenderer are only ever invoked by StringTemplate if they were previously registered via STGroup.registerRenderer(Class<T>, AttributeRenderer<? super T>).
Obviously you will run into trouble if you do this:
This way, StringTemplate will only ever use it on Calendar and Date instances.
That said, one could argue that StringTemplate should explicitly mention this in its Attribute Renderers docs.
Alternatively, StringTemplate could split up DateRenderer into two classes, one implementing AttributeRenderer<Calendar>, the other implementing AttributeRenderer<Date>. That way, the compiler would reject the invalid registerRenderer() call.
However, your proposed solution of changing the toString(...) method to ignore any object which is neither a Date nor a Calendar would only hide the problem of having registered the DateRenderer the wrong way.
for this toString method in picture below
when the type of first parameter is not Calendar or Date, there will be ClassCastException;
So when cast to Date, should add
The text was updated successfully, but these errors were encountered: