commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Neidhart (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (COLLECTIONS-532) MapUtils.predicatedMap(map, keypredicate,valuepredicate) is not working as expected
Date Fri, 30 May 2014 12:54:03 GMT

     [ https://issues.apache.org/jira/browse/COLLECTIONS-532?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Thomas Neidhart updated COLLECTIONS-532:
----------------------------------------

    Issue Type: New Feature  (was: Bug)

> MapUtils.predicatedMap(map, keypredicate,valuepredicate) is not working as expected
> -----------------------------------------------------------------------------------
>
>                 Key: COLLECTIONS-532
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-532
>             Project: Commons Collections
>          Issue Type: New Feature
>          Components: Collection, Map
>    Affects Versions: 4.0
>         Environment: ubuntu/java8
>            Reporter: Bhanupavansingh
>
> I expected that MapUtils.predicatedMap() includes those entries of the specified map
that match the specified key-predicate and specified value-predicate.I expected that entries
that do not match either of the predicates not included i the returned map. 
> But in as per the code of org.apache.commons.collections4.map. PredicatedMap.validate()
>  protected void validate(final K key, final V value) {
>         if (keyPredicate != null && keyPredicate.evaluate(key) == false) {
>             throw new IllegalArgumentException("Cannot add key - Predicate rejected it");
>         }
>         if (valuePredicate != null && valuePredicate.evaluate(value) == false)
{
>             throw new IllegalArgumentException("Cannot add value - Predicate rejected
it");
>         }
>     }
>  if evaluation of key or value predicate fails an IllegalArgumentException is thrown.
> Predicates are passed to input map to test if an entry is to be included or not. If the
evaluation of this predicate itself throws an exception based on result of predicate, then
this method is useless and cannot be used to filter entries of a map(using predicates)



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message