[
http://issues.ops4j.org/browse/QI-271?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13721#action_13721
]
Stanislav Muhametsin commented on QI-271:
-----------------------------------------
Done.
> Builder-pattern for BooleanExpressions in Query API
> ---------------------------------------------------
>
> Key: QI-271
> URL: http://issues.ops4j.org/browse/QI-271
> Project: Qi4j
> Issue Type: Improvement
> Components: Query
> Affects Versions: 1.1
> Environment: Qi4j.
> Reporter: Stanislav Muhametsin
> Assignee: Stanislav Muhametsin
> Fix For: 1.3
>
>
> Currently building boolean expressions (at least more complicated ones) is a
> bit painful. Improve it by extending the builder-pattern to boolean
> expressions. The interface would be something like this
> {code:title=BooleanBuilder.java}
> public interface BooleanBuilder
> {
> public BooleanBuilder and(BooleanExpression another);
> public BooleanBuilder or(BooleanExpression another);
> public BooleanBuilder not();
> public BooleanBuilder reset(BooleanExpression newExp);
> public BooleanExpression getCurrent();
> }
> {code}
> The old API could still be left there for use, in parallel with
> builder-pattern, so that the user may choose whichever way suits him/her best.
> The atomic BooleanExpressions could still be created from QueryExpressions,
> or maybe introduce an own 'BooleanFactory", to say, unit of work.
> Edit:
> Let's say we need to generate "( (x == y) AND (y == z) ) OR (x > y)" boolean
> expression. Using the current API, it would go something like this:
> {code}
> BooleanExpression expr = or(
> and( eq(x, y), eq(y, z)),
> gt(x, y));
> {code}
> Using the builder-pattern, it would go something like this:
> {code}
> BooleanExpression expr = newBBuilder( eq(x,y) )
> .and( eq(y, z) )
> .or( gt(x,y) )
> .createExpression();
> {code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.ops4j.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev