commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Biestro (JIRA)" <>
Subject [jira] [Commented] (JEXL-174) Overloadable property access operators
Date Mon, 24 Aug 2015 16:14:46 GMT


Henri Biestro commented on JEXL-174:

These overloads will also occur in the JexlArithmetic derived class (like any other operator).
The new operators/methods that will be introduced are:
They need to be public and will be 'resolved' using the common method matching algorithm.
The former two will be called when using a '.' as in: {code}{code}
The latter two will be called when using a '[]' as in: {code}foo[bar]{code}
A simplified example where Maps always use their get/put to access properties:
    public static class MapArithmetic extends JexlArithmetic {
        public MapArithmetic(boolean flag) {

        public Object propertyGet(Map<?,?> map, Object identifier) {
            return arrayGet(map, identifier);

        public Object propertySet(Map<Object, Object> map, Object identifier, Object
value) {
             return arraySet(map, identifier, value);

        public Object arrayGet(Map<?,?> map, Object identifier) {
            return map.get(identifier);
        public Object arraySet(Map<Object, Object> map, Object identifier, Object value)
             map.put(identifier, value);
             return value;

> Overloadable property access operators
> --------------------------------------
>                 Key: JEXL-174
>                 URL:
>             Project: Commons JEXL
>          Issue Type: New Feature
>    Affects Versions: 3.0
>            Reporter: Dmitri Blinov
>            Priority: Minor
> In analogy with overloading operators like empty(), size() etc, provide a way to overload
property "get" and "set" operators ([] and .), like 
> {code}
>    public Object getAt(Object obj, Object index) {...}
>    public Object putAt(Object obj, Object index, Object value) {...}
> {code}
> Overloaded operators should be tried before any standard access stategy, ie MAP, POJO

This message was sent by Atlassian JIRA

View raw message