commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitri Blinov (JIRA)" <j...@apache.org>
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

    [ https://issues.apache.org/jira/browse/JEXL-229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16064557#comment-16064557
] 

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
{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&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 
{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<T> and Type<T>
> -------------------------------------------------------------
>
>                 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<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
(v6.4.14#64029)

Mime
View raw message