Skip to content
ohadlights edited this page Sep 17, 2015 · 4 revisions

Welcome to the JQueryable wiki! Here are some snippets...

A complete sample can be found in the repository in the samples project.

Init

private final QueryableList<FruitProduct> fruits = Queryable.newQueryableList();

Filter & Map

@Override
public IQueryable<Apple> getApples() {
    return this.fruits.filter(f -> f instanceof Apple).map(f -> (Apple)f);
}

Sort

Optional<Orange> orange = store.getOranges().sorted(getComparator()).findFirst();
if (orange.isPresent()) {
    System.out.println("The cheap client bought an " + orange.get().toString());
    store.buyOrange(orange.get());
}

Any match

if (store.getFruits().anyMatch(f -> f.getWeight() > 0.4)) {
    System.out.println("The curious client found fruits that weigh more than 0.4");
}

Clone this wiki locally