Skip to content

Commit 3bff425

Browse files
Add JavaDocs to the order method on Query
1 parent 5210447 commit 3bff425

File tree

1 file changed

+34
-11
lines changed
  • src/main/java/org/javawebstack/orm/query

1 file changed

+34
-11
lines changed

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

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -296,20 +296,43 @@ public Query<T> search(String search) {
296296
return this;
297297
}
298298

299-
public Query<T> order(String orderBy) {
300-
return order(orderBy, false);
301-
}
302-
303-
public Query<T> order(String orderBy, boolean desc) {
304-
return order(new QueryColumn(orderBy), desc);
305-
}
306-
307-
public Query<T> order(QueryColumn orderBy, boolean desc) {
308-
boolean success = this.order.add(orderBy, desc);
299+
/**
300+
* Sorts the results by the given column name ascendingly.
301+
*
302+
* @param columnName The name of the column to sort ascendingly by.
303+
* @return The Query object with the given order by information added.
304+
* @throws ORMQueryException if the order operation is called twice on a column specification with the same name.
305+
*/
306+
public Query<T> order(String columnName) throws ORMQueryException {
307+
return order(columnName, false);
308+
}
309+
310+
/**
311+
* Sorts the results by the given column name with the given order direction.
312+
*
313+
* @param columnName The name of the column to sort ascendingly by.
314+
* @param desc If true it will order descendingly, if false it will order ascendingly.
315+
* @return The Query object with the given order by information added.
316+
* @throws ORMQueryException if the order operation is called twice on a column specification with the same name.
317+
*/
318+
public Query<T> order(String columnName, boolean desc) throws ORMQueryException {
319+
return order(new QueryColumn(columnName), desc);
320+
}
321+
322+
/**
323+
* Sorts the results by the given column with the given order direction.
324+
*
325+
* @param column The column encoded as QueryColumn object.
326+
* @param desc If true it will order descendingly, if false it will order ascendingly.
327+
* @return The Query object with the given order by information added.
328+
* @throws ORMQueryException if the order operation is called twice on a column specification with the same name.
329+
*/
330+
public Query<T> order(QueryColumn column, boolean desc) throws ORMQueryException{
331+
boolean success = this.order.add(column, desc);
309332
if(!success) {
310333
throw new ORMQueryException(String.format(
311334
"The column %s could not be ordered %s. This is probably caused by calling .order() on this column twice.",
312-
orderBy.toString(),
335+
column.toString(),
313336
desc ? "descendingly" : "ascendingly"
314337
));
315338
}

0 commit comments

Comments
 (0)