You have a function you wish was part of Queryable.
public static Queryable<String> findFirstWordsOnly(List<String> words)
{
return Query.select(words, w -> {
int i = w.indexOf(' ');
if (i == -1)
{
return w;
}
else
{
return w.substring(0, i);
}
});
}
You can add this to Queryable by implementing the com.lambda.utils.Extendable
interface.
public static class CustomQuery implements Extendable<List<String>>
{
private List<String> caller;
@Override
public void setCaller(List<String> caller)
{
this.caller = caller;
}
Now you can add extension methods that are not static
public Queryable<String> findFirstWordsOnly()
{
return findFirstWordsOnly(caller);
}
and now you can call it as such
Queryable<String> list = Queryable.as("One fish", "two fish", "red fish", "blue fish");
Queryable<String> firstWordsOnlyWithExtension = list.select(String::toUpperCase).use(CustomQuery.class)
.findFirstWordsOnly();
whereas previously you had to use
Queryable<String> firstWordsOnlyStatic = CustomQuery
.findFirstWordsOnly(Query.select(list, String::toUpperCase));