Re: Fluent API addition request

"Jurgen Doll" <[email protected]> Mon, 08 Jul 2024 12:29:24 +0200
Newsgroups gmane.comp.java.cayenne.devel
Organization iVory EMR
Message-ID <op.2qk53awey9kazd@admin-pc>
Hi All

What about borrowing "apply" from Function/UnaryOperator ?
Then we'll have the following API added to Expression:

/**
  * Apply the provided UnaryOperator function to the current Expression.
  */
public Expression apply( UnaryOperator<Expression> op )
{
     return op.apply( this );
}

And the same for ObjectSelect but passing a Consumer instead:

/**
  * Apply the provided Consumer to the current ObjectSelect.
  */
public ObjectSelect<T> apply( Consumer<ObjectSelect<T>> op )
{
     op.accept( this );
     return this;
}

In addition I'd still very much like to have "apply" API that takes a  
boolean parameter as well. For simple cases this will allow user code to  
be more concise without the ternary pattern clutter.

Thoughts, tweaks, likes or objections ?

Regards
Jurgen