commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitri Blinov (JIRA)" <>
Subject [jira] [Commented] (JEXL-229) Introduce new syntax for class literals: Class<T> and Type<T>
Date Tue, 27 Jun 2017 09:43:02 GMT


Dmitri Blinov commented on JEXL-229:

The difference between a dedicated literal, like Class<String>, and a functor classp("String")
in my view is as the difference between literal
and its functional equivalent
new ("java.math.BigDecimal", "1234.33")
the readability, compactness and parse-time checks, which is good for Q&A.

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 
if (obj =~ klass)
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<T> and Type<T>
> -------------------------------------------------------------
>                 Key: JEXL-229
>                 URL:
>             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<String> or Type<Boolean>. Literal
Class<T> should refer to general classes, and literal Type<T> should refer to
primitive type classes. For literals Class<T> 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

View raw message