blob: 94bcda38de513a6c7cf3a3e0e3a228a8eba9cf87 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
package it.niedermann.owncloud.notes.shared.model;
public enum CategorySortingMethod {
SORT_MODIFIED_DESC(0, "MODIFIED DESC"),
SORT_LEXICOGRAPHICAL_ASC(1, "TITLE COLLATE NOCASE ASC");
private final int id;
private final String title; // sorting method OrderBy for SQL
/***
* Constructor
* @param title given sorting method OrderBy
*/
CategorySortingMethod(int id, String title) {
this.id = id;
this.title = title;
}
/***
* Retrieve the sorting method id represented in database
* @return the sorting method id for the enum item
*/
public int getId() {
return this.id;
}
/***
* Retrieve the sorting method order for SQL
* @return the sorting method order for the enum item
*/
public String getTitle() {
return this.title;
}
/***
* Retrieve the corresponding enum value with given the index (ordinal)
* @param id the id of the corresponding enum value stored in DB
* @return the corresponding enum item with the index (ordinal)
*/
public static CategorySortingMethod findById(int id) {
for (CategorySortingMethod csm : values()) {
if (csm.getId() == id) {
return csm;
}
}
return SORT_MODIFIED_DESC;
}
}
|