|
|
@@ -1,11 +1,14 @@
|
|
1
|
1
|
package com.zipcoder.payment;
|
|
2
|
2
|
|
|
3
|
3
|
import java.util.Arrays;
|
|
|
4
|
+import java.util.Comparator;
|
|
4
|
5
|
|
|
5
|
6
|
public class PaymentPresenter {
|
|
6
|
7
|
|
|
7
|
8
|
public String toString(Payment[] payments){
|
|
8
|
|
- Arrays.sort(payments, new PaymentSortDescription());
|
|
|
9
|
+ //Comparator<Payment> shortDescComp = (p1, p2) -> p1.getShortDescription().compareTo(p2.getShortDescription());
|
|
|
10
|
+ Comparator<Payment> shortDescComp = Comparator.comparing(Payment::getShortDescription);
|
|
|
11
|
+ Arrays.sort(payments, shortDescComp);
|
|
9
|
12
|
return createArrayString(payments);
|
|
10
|
13
|
}
|
|
11
|
14
|
|
|
|
@@ -15,7 +18,8 @@ public class PaymentPresenter {
|
|
15
|
18
|
}
|
|
16
|
19
|
|
|
17
|
20
|
public String toStringById(Payment[] payments){
|
|
18
|
|
- Arrays.sort(payments, new PaymentSortID());
|
|
|
21
|
+ Comparator<Payment> sortByID = Comparator.comparing(Payment::getId);
|
|
|
22
|
+ Arrays.sort(payments, sortByID);
|
|
19
|
23
|
return createArrayString(payments);
|
|
20
|
24
|
}
|
|
21
|
25
|
|