commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitri Blinov (JIRA)" <>
Subject [jira] [Commented] (JEXL-151) operators to manipulate j.u.Collection
Date Tue, 21 Jul 2015 08:34:04 GMT


Dmitri Blinov commented on JEXL-151:

For now I have managed to overload operators + and - via JexlArithmetic to support manipulation
of Collection items, it's odd-looking a bit, but works. Another case is =~ operator which
is implemented inside and since can not be overloaded, but as I see it requires
only three lines of code to implement

            // try contains on collection
            if (right instanceof Collection<?>) {
+               if (left instanceof Collection<?>) 
+                  return ((Collection<?>) right).containsAll((Collection<?>)
+               else
                   return ((Collection<?>) right).contains(left);

Can we include it in near future?

> operators to manipulate j.u.Collection
> --------------------------------------
>                 Key: JEXL-151
>                 URL:
>             Project: Commons JEXL
>          Issue Type: New Feature
>    Affects Versions: 3.0
>            Reporter: Dmitri Blinov
>            Priority: Minor
>             Fix For: Later
> New operators to add or remove collection items to/from Collection. Operators can be
named as += and -= respectively, or any other way. Operator += can be mapped to Collection.addAll(Collection
c) if right argument is Collection or to Collection.add(Object o) otherwise. Operator -= can
be mapped to Collection.removeAll(Collection c) if right argument is Collection or to Collection.remove(Object
o) otherwise. Extend operators =~  (!~) to support CollectionA =~ CollectionB usage, in which
case it should map to B.containsAll(A) operation.

This message was sent by Atlassian JIRA

View raw message