[
https://issues.apache.org/jira/browse/SLING-9968?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17388908#comment-17388908
]
Eric Norman commented on SLING-9968:
------------------------------------
[~radu] Thanks for the clarification. Do you think that the SLING-5053
conclusion and reasoning is still relevant in the latest codebase?
I could be wrong, but from my quick testing, it doesn't appear that the
SLING-5053 use case ever hits the ObjectModel#toString code path. The enum
equality operation appears to be using the BinaryOperator#strictEq function to
do the comparison of enum to string which doesn't use Enum#name() nor
Enum#toString() at all.
FYI: The Enum javadoc also states the following which is why I was expecting
ObjectModel#toString to call the Enum#toString method instead of Enum#name:
{quote}Most programmers should use the
[{{toString()}}|https://docs.oracle.com/javase/8/docs/api/java/lang/Enum.html#toString--]
method in preference to this one, as the toString method may return a more
user-friendly name.
{quote}
> ObjectModel.toString() should support more classes
> --------------------------------------------------
>
> Key: SLING-9968
> URL: https://issues.apache.org/jira/browse/SLING-9968
> Project: Sling
> Issue Type: Improvement
> Components: Scripting
> Affects Versions: Scripting HTL Runtime 1.2.4-1.4.0
> Reporter: Konrad Windszus
> Assignee: Konrad Windszus
> Priority: Major
> Fix For: Scripting HTL Runtime 1.2.6-1.4.0
>
>
> For getter methods returning e.g. a {{java.net.URI}} there is no implicit
> {{toString()}} being applied. When looking at the HTL specs it seems not
> defined how to deal with complex objects
> (https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#1152-string),
> but given that enums and primitives are automatically converted
> (https://github.com/apache/sling-org-apache-sling-scripting-sightly-runtime/blob/6cbd676a8875af756e6e43b38c39ba9e4784dc4e/src/main/java/org/apache/sling/scripting/sightly/render/ObjectModel.java#L238)
> already, I am wondering why other types like {{URI}} or {{URL}} are not
> supported.
> Is there any harm when doing object.toString() as fallback?
--
This message was sent by Atlassian Jira
(v8.3.4#803005)