Skip to content

Commit 50d5958

Browse files
abdurasul29052002mshabarov
authored andcommitted
feat: Add a short method to SortDirection enum (#21706)
The SortDirection enum only provides name(), getOpposite() methods. This change introduces a new method called getShortName() which returns shortened version of SortDirection. This short names can be useful in the SQL queries etc. Fixes #21693 (cherry picked from commit 1877b2d)
1 parent 75a00d1 commit 50d5958

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

flow-data/src/main/java/com/vaadin/flow/data/provider/SortDirection.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,14 @@ public enum SortDirection {
4141
public SortDirection getOpposite() {
4242
return ASCENDING.equals(this) ? DESCENDING : ASCENDING;
4343
}
44+
45+
/**
46+
* Get the short name of the sort direction.
47+
*
48+
* @return The shortened representation of the sort direction, either "asc"
49+
* or "desc"
50+
*/
51+
public String getShortName() {
52+
return ASCENDING.equals(this) ? "asc" : "desc";
53+
}
4454
}

0 commit comments

Comments
 (0)