19WAS85 / coollection

A cool way to manipulate collections in Java.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how is one supposed to chain "and" with "or"

buckyball opened this issue · comments

maybe a simple question, but I cannot make it work. Example:

from(article).where( "customerNr", eq(custno) )
          .and    ("articlenumber_intern", startsWith(searchTerm))
          .or     ("articlenumber_extern", startsWith(searchTerm))
          .all()

that way, coolection will only return items that are matched by "articlenumber_intern", ignoring the "or" criteria.

Oh, btw, as you can see I added a "startsWith" critera because the contains function wasn't sufficient for me. I would like to suggest to add it in your coolection lib, as this seems to be a common requirement when working with lists.

Thanks for your wonderful little helper, coolection rocks
!

commented

Hi,

I have similar problem using "or" matcher. I have query like this:

from(some_list).where("prop1", eq(some_val))
.or("prop2", eq(some_val))
.or("prop3", eq(some_val))
.all();

but I receive objects that match only first matcher :( Any solutions yet?

Thanks :)