File tree Expand file tree Collapse file tree
libraries/src/test/java/com/baeldung/commons/collections Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,8 +54,10 @@ public void givenTwoSortedLists_whenCollated_thenSorted() {
5454
5555 @ Test
5656 public void givenListOfCustomers_whenTransformed_thenListOfAddress () {
57- Collection <Address > addressCol = CollectionUtils .collect (list1 , customer -> {
58- return new Address (customer .getLocality (), customer .getCity (), customer .getZip ());
57+ Collection <Address > addressCol = CollectionUtils .collect (list1 , new Transformer <Customer , Address >() {
58+ public Address transform (Customer customer ) {
59+ return new Address (customer .getLocality (), customer .getCity (), customer .getZip ());
60+ }
5961 });
6062
6163 List <Address > addressList = new ArrayList <>(addressCol );
@@ -65,9 +67,13 @@ public void givenListOfCustomers_whenTransformed_thenListOfAddress() {
6567
6668 @ Test
6769 public void givenCustomerList_whenFiltered_thenCorrectSize () {
68-
69- boolean isModified = CollectionUtils .filter (linkedList1 , customer -> Arrays .asList ("Daniel" ,"Kyle" ).contains (customer .getName ()));
70-
70+
71+ boolean isModified = CollectionUtils .filter (linkedList1 , new Predicate <Customer >() {
72+ public boolean evaluate (Customer customer ) {
73+ return Arrays .asList ("Daniel" ,"Kyle" ).contains (customer .getName ());
74+ }
75+ });
76+
7177 //filterInverse does the opposite. It removes the element from the list if the Predicate returns true
7278 //select and selectRejected work the same way except that they do not remove elements from the given collection and return a new collection
7379
You can’t perform that action at this time.
0 commit comments