Skip to content

Commit 5cf196c

Browse files
author
Psilo
committed
fix documentation and bump version
1 parent 0867eb6 commit 5cf196c

File tree

4 files changed

+45
-9
lines changed

4 files changed

+45
-9
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<modelVersion>4.0.0</modelVersion>
1919
<artifactId>http-server</artifactId>
20-
<version>0.1.8</version>
20+
<version>0.1.9</version>
2121
<name>HttpServer</name>
2222
<packaging>jar</packaging>
2323

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ public GenericHandlerGroupBuilder<P, J, E> getListInterceptor(final GetListInter
106106
* You can specify every important part of it (select-clause, where-clause,
107107
* join-clause and order-by-clause) and utilizes its own parser for the
108108
* where-clause ({@link InterceptorParamBuilder#query(String)}).
109-
*
110-
* @return
109+
*
110+
* @return a new instance of the {@link InterceptorParamBuilder}
111111
*/
112112
public InterceptorParamBuilder<P, J, E> getListInterceptor() {
113113
return new InterceptorParamBuilder<>(this, (passedData, query) -> {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
public class Information {
44
public static final String name = "Http-Server";
5-
public static final String buildTime = "2020-10-22T08:20:38Z";
6-
public static final String pomVersion = "0.1.6";
5+
public static final String buildTime = "2020-10-23T12:37:54Z";
6+
public static final String pomVersion = "0.1.8";
77
}

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

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,48 @@ public class InterceptorParamBuilder<P extends BasicJpa, J extends BasicJson, E>
1818
private String orderByClause = "";
1919
private String query = "";
2020

21+
/**
22+
* This helps you to add something to the select-clause, like 'distinct' or a
23+
* limit.<br>
24+
* The standard table always gets the alias 'o'.
25+
*
26+
* @param selectClause the clause (Example:
27+
* {@code 'DISTINCT ' + ThisJpa.class.getSimpleName + ' AS o'})
28+
* @return itself in order to provide a fluent interface.
29+
*/
2130
public InterceptorParamBuilder<P, J, E> select(final String selectClause) {
22-
this.selectClause = selectClause;
31+
this.selectClause = selectClause.trim().toLowerCase().startsWith("select")
32+
? selectClause.trim().substring(6).trim()
33+
: selectClause.trim();
2334
return this;
2435
}
2536

37+
/**
38+
* Here you can specify a special join-clause that will be added to your query
39+
* later on.<br>
40+
* The aliases you give here may be used in all other parts of the query.
41+
*
42+
* @param joinClause the clause (Example:
43+
* {@code ' JOIN ' + MyClass.getSimpleName() + ' AS f ON o.fId=f.id'})
44+
* @return itself in order to provide a fluent interface.
45+
*/
2646
public InterceptorParamBuilder<P, J, E> join(final String joinClause) {
27-
this.joinClause = joinClause.startsWith(" ") ? joinClause : " " + joinClause;
47+
this.joinClause = " " + joinClause.trim();
2848
return this;
2949
}
3050

51+
/**
52+
* Here you can specify a special order-by-clause that will be appended to your
53+
* SQL-query later on.
54+
* <p>
55+
* May or may not start with 'order by', your choice.
56+
*
57+
* @param orderByClause the clause (Example: {@code 'o.name DESC'}
58+
* @return itself in order to provide a fluent interface.
59+
*/
3160
public InterceptorParamBuilder<P, J, E> orderBy(final String orderByClause) {
32-
this.orderByClause = orderByClause.startsWith(" ") ? orderByClause : " " + orderByClause;
61+
this.orderByClause = orderByClause.trim().toLowerCase().startsWith("order by") ? " " + orderByClause.trim()
62+
: " ORDER BY " + orderByClause.trim();
3363
return this;
3464
}
3565

@@ -52,7 +82,7 @@ public InterceptorParamBuilder<P, J, E> orderBy(final String orderByClause) {
5282
* preceded by a '~'.<br>
5383
* {@code Example: 'dbEnumField = :jsonField[~MyEnumClass]'}<br>
5484
* <p>
55-
* - Term operators are: >, <, >=, <=, = or ==, <> or != and LIKE (which
85+
* - Term operators are: {@code >, <, >=, <=, = or ==, <> or != and LIKE} (which
5686
* automatically adds the wildcards like %yourvalue% before going to the
5787
* database).<br>
5888
* - Every term may be optional when you precede the DB-field-name with a
@@ -69,6 +99,12 @@ public InterceptorParamBuilder<P, J, E> query(final String query) {
6999
return this;
70100
}
71101

102+
/**
103+
* Builds this Interceptor and returns you to the fluent interface of the
104+
* underlying {@link GenericHandlerGroupBuilder}.
105+
*
106+
* @return the {@link GenericHandlerGroupBuilder} you came from.
107+
*/
72108
public GenericHandlerGroupBuilder<P, J, E> build() {
73109
InterceptorData r = InterceptorData.builder()
74110
.selectClause(selectClause)

0 commit comments

Comments
 (0)