1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.uiextension.internal.filter; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.Collections; |
24 |
|
import java.util.Comparator; |
25 |
|
import java.util.List; |
26 |
|
|
27 |
|
import javax.inject.Named; |
28 |
|
import javax.inject.Singleton; |
29 |
|
|
30 |
|
import org.xwiki.component.annotation.Component; |
31 |
|
import org.xwiki.uiextension.UIExtension; |
32 |
|
import org.xwiki.uiextension.UIExtensionFilter; |
33 |
|
|
34 |
|
|
35 |
|
@link |
36 |
|
|
37 |
|
@version |
38 |
|
@since |
39 |
|
|
40 |
|
@Component |
41 |
|
@Singleton |
42 |
|
@Named("sortById") |
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.25 |
|
43 |
|
public class SortByIdFilter implements UIExtensionFilter |
44 |
|
{ |
45 |
|
|
46 |
|
@link |
47 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 1 |
|
48 |
|
public class UIExtensionIdComparator implements Comparator<UIExtension> |
49 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
50 |
17 |
@Override... |
51 |
|
public int compare(UIExtension source, UIExtension target) |
52 |
|
{ |
53 |
17 |
return source.getId().compareToIgnoreCase(target.getId()); |
54 |
|
} |
55 |
|
} |
56 |
|
|
57 |
|
|
58 |
|
@param@link |
59 |
|
@param |
60 |
|
@return |
61 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
62 |
2 |
@Override... |
63 |
|
public List<UIExtension> filter(List<UIExtension> extensions, String... ignored) |
64 |
|
{ |
65 |
2 |
List<UIExtension> results = new ArrayList<UIExtension>(); |
66 |
2 |
results.addAll(extensions); |
67 |
2 |
Collections.sort(results, new UIExtensionIdComparator()); |
68 |
|
|
69 |
2 |
return results; |
70 |
|
} |
71 |
|
} |