[jira] [Commented] (JEXL-229) Introduce new syntax for class literals: Class and Type
[ https://issues.apache.org/jira/browse/JEXL-229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16182695#comment-16182695 ] Dmitri Blinov commented on JEXL-229: I have found another solution to this problem. I have adjusted the {{JexlContext}} class to resolve ant-ish style context properties like for example {{java.lang.Integer}} to the instances of corresponding {{Class}} so it is now as easy to address {{Class}} objects as to write {code}if (obj =~ java.util.Map){code} Furthermore, I have added a property resolver for {{Class}} objects to return static class members, like for example {code}var one = java.math.BigInteger.ONE{code} This also allowed me to access {{Class}} objects for primitive types, since they are referenced via {{TYPE}} static member of corresponding boxed type, like the following {code}java.lang.Integer.TYPE{code} I think I have achieved what I was aiming at, a clean solution without functors and need to use type names as strings. So I think it is better now to close this issue. > Introduce new syntax for class literals: Class and Type > - > > Key: JEXL-229 > URL: https://issues.apache.org/jira/browse/JEXL-229 > Project: Commons JEXL > Issue Type: New Feature >Affects Versions: 3.1 >Reporter: Dmitri Blinov >Priority: Minor > > For the purpose of type checking in jexl, It whould be convenient to have > some simple syntax for referring to class types, like Class or > Type. Literal Class should refer to general classes, and literal > Type should refer to primitive type classes. For literals Class it > could be possible to specify partal class name, which should resolve to > classes in basic packages like java.lang and java.util, for example. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (JEXL-229) Introduce new syntax for class literals: Class and Type
[ https://issues.apache.org/jira/browse/JEXL-229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16064557#comment-16064557 ] Dmitri Blinov commented on JEXL-229: The difference between a dedicated literal, like Class, and a functor classp("String") in my view is as the difference between literal {code} 1234.33B {code} and its functional equivalent {code} new ("java.math.BigDecimal", "1234.33") {code} the readability, compactness and parse-time checks, which is good for Q The use case I'm after is to get away from now existing functors like {{isMap()}}, {{isCollection()}} {{isSet()}} and to come to more generic type checking. I have overloaded the {{=~}} operator to be used with right-hand {{Class}} instances by calling either Class.isInstance() for objects or Class.isAssignableFrom() for other Classes, for example {code} if (obj =~ klass) {code} so I think we can get along without introducing {{instanceof}} operator, but for the types, as they are very basic Java elements for scripting, like primitives, IMHO, it would be desirable to have a special language construct. > Introduce new syntax for class literals: Class and Type > - > > Key: JEXL-229 > URL: https://issues.apache.org/jira/browse/JEXL-229 > Project: Commons JEXL > Issue Type: New Feature >Affects Versions: 3.1 >Reporter: Dmitri Blinov >Priority: Minor > > For the purpose of type checking in jexl, It whould be convenient to have > some simple syntax for referring to class types, like Class or > Type. Literal Class should refer to general classes, and literal > Type should refer to primitive type classes. For literals Class it > could be possible to specify partal class name, which should resolve to > classes in basic packages like java.lang and java.util, for example. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (JEXL-229) Introduce new syntax for class literals: Class and Type
[ https://issues.apache.org/jira/browse/JEXL-229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16062958#comment-16062958 ] Henri Biestro commented on JEXL-229: A set of use cases is missing. However and in general, I suspect a new syntax is not warranted. Can you give produce an example/test using a classp(...) or typep(...) function/functor in a namespace so what you're after is made clear? > Introduce new syntax for class literals: Class and Type > - > > Key: JEXL-229 > URL: https://issues.apache.org/jira/browse/JEXL-229 > Project: Commons JEXL > Issue Type: New Feature >Affects Versions: 3.1 >Reporter: Dmitri Blinov >Priority: Minor > > For the purpose of type checking in jexl, It whould be convenient to have > some simple syntax for referring to class types, like Class or > Type. Literal Class should refer to general classes, and literal > Type should refer to primitive type classes. For literals Class it > could be possible to specify partal class name, which should resolve to > classes in basic packages like java.lang and java.util, for example. -- This message was sent by Atlassian JIRA (v6.4.14#64029)