Skip to content

Commit 5a74b53

Browse files
Add JavaDocs to QueryOrderBy
1 parent 37ed312 commit 5a74b53

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/main/java/org/javawebstack/orm/query/QueryOrderBy.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,44 @@
55
import java.util.LinkedList;
66
import java.util.stream.Collectors;
77

8+
/**
9+
* The QueryOrderBy class serves as an aggregation of order by elements. It extends a list, because the order of the
10+
* order by statements is of relevance.
11+
*/
812
public class QueryOrderBy extends LinkedList<QueryOrderByElement>{
913

14+
/**
15+
* Add a new order by statement. If a statement with the same column name already exists it will not add the
16+
* statement.
17+
*
18+
* @param columnName The column name to order by.
19+
* @param desc If the column should be order descendingly.
20+
* @return True if adding the statement was successful. False otherwise.
21+
*/
1022
public boolean add(String columnName, boolean desc) {
1123
return this.add(new QueryColumn(columnName), desc);
1224
}
1325

26+
/**
27+
* Add a new order by statement. If a statement with the same column name already exists it will not add the
28+
* statement.
29+
*
30+
* @param column The column to be ordered by. It will retrieve the name from the QueryColumn.
31+
* @param desc If the column should be order descendingly.
32+
* @return True if adding the statement was successful. False otherwise.
33+
*/
1434
public boolean add(QueryColumn column, boolean desc) {
1535
return this.add(new QueryOrderByElement(column, desc));
1636
}
1737

1838
@Override
39+
/**
40+
* Add a new order by statement. If a statement with the same column name already exists it will not add the
41+
* statement.
42+
*
43+
* @param element The direct QueryOrderByElement which encodes the order by statement.
44+
* @return True if adding the statement was successful. False otherwise.
45+
*/
1946
public boolean add(QueryOrderByElement element) {
2047
boolean hasBeenAdded = false;
2148
if(!willOverwrite(element))
@@ -28,6 +55,8 @@ private boolean willOverwrite(QueryOrderByElement element) {
2855
return this.stream().anyMatch(element::hasEqualColumn);
2956
}
3057

58+
59+
// The toString methods are specific to MySQL so they might have to be replaced later on.
3160
@Override
3261
public String toString() {
3362
return toString(null);

0 commit comments

Comments
 (0)