aempojosightlyhtl

Can I use other prefixes other than 'is' in WCMUsePojo boolean getters?


I've seen conventions in Java pojos that use can, has, and should instead of the usual is. However, in AEM 6.1 we have WCMUsePojo right? is works for sure, and I've tried has but hasn't worked. Is this a bug or WCMUsePojo never really intended other getter prefixes for booleans other than is?


Solution

  • No.

    The Use api looks at a Pojo from the perspective of a Java Bean.

    http://download.oracle.com/otndocs/jcp/7224-javabeans-1.01-fr-spec-oth-JSpec/

    For boolean values the convention is that the value be prefixed with an 'is' or a 'get' prefix. Using the prefix "has" has never been a part of the JavaBean specification. However that doesn't mean that the Use API shouldn't do that. Contextually "has" makes more sense sometimes. So you may be able to open a request or inquire about having that added to the api support. The maintainers of HTL are the committers to the Apache Sling project

    https://sling.apache.org/

    And if you are interested the source code for HTL is here https://github.com/apache/sling-org-apache-sling-scripting-sightly