Skip to content

Commit 94ee35b

Browse files
BAEL-965 - reverting to anonymous classes
1 parent 647455b commit 94ee35b

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

‎libraries/src/test/java/com/baeldung/commons/collections/CollectionUtilsGuideTest.java‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)