Skip to content

Commit 0867eb6

Browse files
author
Psilo
committed
tidying up and add comments
1 parent c16901a commit 0867eb6

File tree

3 files changed

+40
-11
lines changed

3 files changed

+40
-11
lines changed

src/main/java/info/unterrainer/commons/httpserver/GenericHandlerGroupBuilder.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ public GenericHandlerGroupBuilder<P, J, E> getListInterceptor(final GetListInter
100100
return this;
101101
}
102102

103+
/**
104+
* Gives you a {@link InterceptorParamBuilder} object that allows you to declare
105+
* an interceptor with minimal code.<br>
106+
* You can specify every important part of it (select-clause, where-clause,
107+
* join-clause and order-by-clause) and utilizes its own parser for the
108+
* where-clause ({@link InterceptorParamBuilder#query(String)}).
109+
*
110+
* @return
111+
*/
103112
public InterceptorParamBuilder<P, J, E> getListInterceptor() {
104113
return new InterceptorParamBuilder<>(this, (passedData, query) -> {
105114
getListInterceptors.add((ctx, hu) -> {

src/main/java/info/unterrainer/commons/httpserver/interceptors/InterceptorParamBuilder.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,37 @@ public InterceptorParamBuilder<P, J, E> orderBy(final String orderByClause) {
3333
return this;
3434
}
3535

36+
/**
37+
* This is where you declare your rules that will construct your query.
38+
* <p>
39+
* - The operators are 'AND' and 'OR' and you may use parentheses '(' and ')' to
40+
* group your sub-expressions.<br>
41+
* {@code Example: 'term1 AND (term2 OR term3)'}<br>
42+
* - Operator precedence automatically is AND before OR.<br>
43+
* - A term starts with a DB-field followed by either an operator and a
44+
* JSON-field, or a null-operator.<br>
45+
* - JSON-fields start with ':' and end on a bracket-expression containing the
46+
* type of field.<br>
47+
* - Allowed fields are:
48+
* {@code string, boolean, int, long, float, double and datetime} (The system
49+
* knows how to convert these to DB-values).<br>
50+
* {@code Example: 'dbFieldName = :jsonName[string] AND dbId = :id[long] OR otherDbField IS NOT NULL AND anotherDbField IS NULL'}<br>
51+
* - When using Enums you have to specify the type of the Enum to cast to
52+
* preceded by a '~'.<br>
53+
* {@code Example: 'dbEnumField = :jsonField[~MyEnumClass]'}<br>
54+
* <p>
55+
* - Term operators are: >, <, >=, <=, = or ==, <> or != and LIKE (which
56+
* automatically adds the wildcards like %yourvalue% before going to the
57+
* database).<br>
58+
* - Every term may be optional when you precede the DB-field-name with a
59+
* '?'.<br>
60+
* {@code Example: '?dbFieldName = :jsonName[string] AND dbId = :id[long]' requested with an empty 'jsonName' will result in 'dbId = :id[long]'}
61+
* Everything is case-insensitive except for the parameters of course.
62+
*
63+
* @param query a string that will be parsed constructing your where-clause and
64+
* all parameter-assignments
65+
* @return itself in order to provide a fluent interface.
66+
*/
3667
public InterceptorParamBuilder<P, J, E> query(final String query) {
3768
this.query = query;
3869
return this;

src/main/java/info/unterrainer/commons/httpserver/rql/RqlDataElementType.java

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)