I am looking for Java Libraries that will allow me to query collections. I have stumbled across jFilter an JoSql.
However it seems that JoSql has been inactive since 2010 and has had only 2 releases. jFilter seems to be fairly new and hasn't had any new releases since last year.
The small number of search result, when googling either of them, suggests to me that they are not used widely.
Have you got any suggestions regarding these libraries, or know of more active once?
The Collection interface is used to pass around collections of objects where maximum generality is desired. For example, by convention all general-purpose collection implementations have a constructor that takes a Collection argument.
It is the primary class for interacting with the Query Manager (class QueryManager), which executes each query. QueryObject holds the query information read by the Query Manager, and is used to set select fields for an object and to set conditions on object fields.
All the collection classes are present in java. util and java. util. concurrent package.
The collections in java provide an architecture to store and manipulate the group of objects, interfaces and classes. A collection is a group of objects or it is a single entity that represents multiple objects.
I have used CqEngine successfuly in my company (https://code.google.com/p/cqengine/)
When you instantiate a collection, you can easily define a set of indexes. This is much more powerful than predicates.
Also, when you will perform a search on your collection, CqEngine will not iterate on the whole collection then check if each record matches with the predicate. Instead, it will directly find the matching records in a Map like data structure. Hence you will have excellent performance.
You can look at Commons Collections, and more specifically CollectionUtils.filter(Collection, Filter)
.
Another option would be Google Guava, which has Iterables.filter(Iterable<T>, Predicate<? super T>)
.
The choice is yours.
Probably it's too late but it might be helpful for someone else, You could use,
https://code.google.com/p/joquery/
where it supports following syntax,
Collection<Dto> testList = new ArrayList<>();
Filter<Dto> query = CQ.<Dto>filter(testList)
.where()
.property("id").eq().value(1);
Collection<Dto> filtered = query.list();
class Dto
{
private int id;
private String text;
public int getId()
{
return id;
}
public int getText()
{
return text;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With