Tony CHEMIT pushed to branch develop-7.x at ultreiaio / ird-observe
Commits:
-
3655d085
by tchemit at 2019-01-02T14:37:30Z
2 changed files:
- dto/src/main/java/fr/ird/observe/dto/data/longline/TripLonglineHelper.java
- dto/src/main/java/fr/ird/observe/dto/data/seine/TripSeineHelper.java
Changes:
| ... | ... | @@ -22,19 +22,18 @@ package fr.ird.observe.dto.data.longline; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
-import java.util.ArrayList;
|
|
| 25 |
+import java.util.Comparator;
|
|
| 26 | 26 |
import java.util.List;
|
| 27 |
-import java.util.Map;
|
|
| 28 |
-import java.util.TreeMap;
|
|
| 27 |
+import java.util.stream.Collectors;
|
|
| 29 | 28 |
|
| 30 | 29 |
public class TripLonglineHelper extends GeneratedTripLonglineHelper {
|
| 31 | 30 |
|
| 32 | 31 |
public static List<TripLonglineReference> sort(List<TripLonglineReference> data) {
|
| 33 |
- Map<Object, TripLonglineReference> map = new TreeMap<>();
|
|
| 34 |
- for (TripLonglineReference datum : data) {
|
|
| 35 |
- map.put(datum.getStartDate(), datum);
|
|
| 36 |
- }
|
|
| 37 |
- return new ArrayList<>(map.values());
|
|
| 32 |
+ return data
|
|
| 33 |
+ .stream()
|
|
| 34 |
+ .sorted(Comparator.comparing(TripLonglineReference::getStartDate)
|
|
| 35 |
+ .thenComparing(TripLonglineReference::getEndDate)
|
|
| 36 |
+ .thenComparing(TripLonglineReference::getVesselLabel))
|
|
| 37 |
+ .collect(Collectors.toList());
|
|
| 38 | 38 |
}
|
| 39 |
- |
|
| 40 | 39 |
}
|
| ... | ... | @@ -22,18 +22,18 @@ package fr.ird.observe.dto.data.seine; |
| 22 | 22 |
* #L%
|
| 23 | 23 |
*/
|
| 24 | 24 |
|
| 25 |
-import java.util.ArrayList;
|
|
| 25 |
+import java.util.Comparator;
|
|
| 26 | 26 |
import java.util.List;
|
| 27 |
-import java.util.Map;
|
|
| 28 |
-import java.util.TreeMap;
|
|
| 27 |
+import java.util.stream.Collectors;
|
|
| 29 | 28 |
|
| 30 | 29 |
public class TripSeineHelper extends GeneratedTripSeineHelper {
|
| 31 | 30 |
|
| 32 | 31 |
public static List<TripSeineReference> sort(List<TripSeineReference> data) {
|
| 33 |
- Map<Object, TripSeineReference> map = new TreeMap<>();
|
|
| 34 |
- for (TripSeineReference datum : data) {
|
|
| 35 |
- map.put(datum.getStartDate(), datum);
|
|
| 36 |
- }
|
|
| 37 |
- return new ArrayList<>(map.values());
|
|
| 32 |
+ return data
|
|
| 33 |
+ .stream()
|
|
| 34 |
+ .sorted(Comparator.comparing(TripSeineReference::getStartDate)
|
|
| 35 |
+ .thenComparing(TripSeineReference::getEndDate)
|
|
| 36 |
+ .thenComparing(TripSeineReference::getVesselLabel))
|
|
| 37 |
+ .collect(Collectors.toList());
|
|
| 38 | 38 |
}
|
| 39 | 39 |
}
|