commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matt Benson (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (COLLECTIONS-305) functors filtering on bean properties using(== ,!=, >,>=.>.>=. isNull, Like,..... )
Date Fri, 20 May 2011 13:42:47 GMT

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

Matt Benson commented on COLLECTIONS-305:
-----------------------------------------

You'd have to search the dev list, but IIRC we decided to concentrate all functor stuff on
[functor] (which just needs a little more interest to be ready to graduate from the sandbox).
 An issue like this, however, IMO brings up the further dilemma of deciding how to deal with
gray areas between components.  Is this functor-related code, or bean-related code?

> functors filtering on bean properties  using(== ,!=, >,>=.>.>=. isNull, Like,.....
) 
> -------------------------------------------------------------------------------------
>
>                 Key: COLLECTIONS-305
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-305
>             Project: Commons Collections
>          Issue Type: Improvement
>          Components: Functor
>    Affects Versions: 3.2
>            Reporter: Anil K.Kinge
>         Attachments: functors.propertypredicates.new.diff
>
>
> In my current project I created a set of new Predicates that I call as Property Predicates.
 These predicates can used to filter a collection based on property values.  
> For example we have :
> Class Foo{
> 	String name;
> 	Int age;
> 	Address address;
> }
> Address{
> 	String street;
> 	String zip;
> }
> Collection<Foo> myFoos ;
> And we want to find all the Foo in myFoos with name that starts with A, and age >
40 and who are living at Zip 07095 we can create a Predicate like follows:
> Predicate p =  new PropertyLikePredicate("name","A*")
> .andGreaterThan("age",40)
> .andEquals(address.zip,"07095");
> Note: Like supports wildcards '*' and '?'
> What is even better is that these predicates work with collections too.  What I mean
is if we have :
> FooBar{
> 	String name;
> 	Collection<Address> addresses;
> }
> And you want to locate someone with a zip 07095 as part of anyof its' addresses all we
need is to create a predicate :
> Predicate p = new PropertyEqualsPredicate("addresses[].zip","07095");
> My Predicate chain currently supports the following features:
> 1.	andEquals
> 2.	orEquals
> 3.	andNotEquals
> 4.	orNotEquals
> 5.	andLike
> 6.	orLike
> 7.	andGreatorThan
> 8.	orGreatorThan
> 9.	andGreatorThanOrEquals
> 10.	orGreatorThanOrEquals
> 11.	andLessThan
> 12.	orLessThan
> 13.	andLessThanOrEquals
> 14.	orLessThanOrEquals
> 15.	isNull
> 16.	isNotNull
> 17.	orNull
> 18.	orNotNull
> 19.	orNullOrEmpty
> 20.	orNotNullOrEmpty
> 21.	andNullOrEmpty
> 22.	andNotNullOrEmpty
> All features have accompanying testcases.  In my opinion this is a powerful addition
to the functors and I would like to contribute this work to the commons-collection.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message