On Fri, Jun 14, 2019 at 11:59 AM 'Maverick Skywalker' via jOOQ User Group <
[email protected]> wrote:
> Hi Lukas,
>
> but how would such an API be configured? How would it detect what kind of
>> predicate you want to have expressed given only an input record?
>>
> The current idea was to keep it as simple as possible and to provide a
> company object for each condition type ("like", ">", and so on). The
> subject is to implement a filter mechanism of a table, in each column you
> have one filter input as String. I'm building everything from scratch, thus
> I'm free how to implement it.
>
I see, interesting. I'll give this some thoughts. Surely, the default of
using "=" can be overridden in a meaningful way that is easy to discover
and simple to use. I'll revert back to this discussion once I have a more
clear idea.
>
> the obvious solution is to write your own QBE API
>>
> I have started to prototype such a function by my own, but I struggle to
> build the condition based on the sniped below, connected by "and".
>
> public static Condition likeCondition(Record record) {
> Field<?>[] fields = record.fields();
>
> for(int i = 0; i < fields.length; ++i) {
> fields[i].like(record.get(i).toString());
> }
> return null;
> }
>
> Do you have any suggestions? ( I can't create a Condition object, thats
> the problem thus far)
>
You can append conditions like this, in the loop:
Condition condition = DSL.noCondition(); // Or DSL.trueCondition()
for (...)
condition = condition.and(...);
Alternatively, you can Stream.reduce a set of conditions using
Condition::and, or use DSL.and(Condition...) or DSL.and(Collection<?
extends Condition)
I hope this helps,
Lukas
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jooq-user/CAB4ELO5Zx-e%3Dh1%3DmsrPTgd%3D1s5god%3DstFk5HP0YuVkTZwpGVag%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.