|
Project Information
Featured
Downloads
Links
|
FilterQ alleviates the pain of using multiple if-else(..) checks when iterating over a collection to obtain a smaller view of that collection. FilterQ uses an EDSL for filtering iterable objects. Usage Sampleimport static com.gotobject.filter.FilterQ.*; final Iterable<Integer> a = Arrays.asList(1, 2, 3, 40, 20, 30, 100); final Iterable<Integer> b = from(a).where(gt(20).and(lt(100))).skip(1); // result (30) What we are writing here to FilterQ is to give me all of the elements from a that are greater than 20 and less than 100, but please, when returning the filtered iterable, skip the first element of the filtered iterable. Another Usage Sample This sample prints the name of each number in an integer array by indexing into a second array that contains the names. And another one...import static com.gotobject.filter.FilterQ.*; final Iterable<Integer> n = from(range(1,1000)).where(numIsPrime()).select(not(eq(117))); System.out.println(n); This example will print ALL prime numbers found in the range (0...1000), but 117. |