From 94ee35bed7ec1dbb74bcc6a8336da7f0053c8163 Mon Sep 17 00:00:00 2001 From: slavisa-baeldung Date: Sat, 8 Jul 2017 07:36:06 +0100 Subject: [PATCH] BAEL-965 - reverting to anonymous classes --- .../collections/CollectionUtilsGuideTest.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libraries/src/test/java/com/baeldung/commons/collections/CollectionUtilsGuideTest.java b/libraries/src/test/java/com/baeldung/commons/collections/CollectionUtilsGuideTest.java index 9166865484..90e30b01dc 100644 --- a/libraries/src/test/java/com/baeldung/commons/collections/CollectionUtilsGuideTest.java +++ b/libraries/src/test/java/com/baeldung/commons/collections/CollectionUtilsGuideTest.java @@ -54,8 +54,10 @@ public class CollectionUtilsGuideTest { @Test public void givenListOfCustomers_whenTransformed_thenListOfAddress() { - Collection
addressCol = CollectionUtils.collect(list1, customer -> { - return new Address(customer.getLocality(), customer.getCity(), customer.getZip()); + Collection
addressCol = CollectionUtils.collect(list1, new Transformer() { + public Address transform(Customer customer) { + return new Address(customer.getLocality(), customer.getCity(), customer.getZip()); + } }); List
addressList = new ArrayList<>(addressCol); @@ -65,9 +67,13 @@ public class CollectionUtilsGuideTest { @Test public void givenCustomerList_whenFiltered_thenCorrectSize() { - - boolean isModified = CollectionUtils.filter(linkedList1, customer -> Arrays.asList("Daniel","Kyle").contains(customer.getName())); - + + boolean isModified = CollectionUtils.filter(linkedList1, new Predicate() { + public boolean evaluate(Customer customer) { + return Arrays.asList("Daniel","Kyle").contains(customer.getName()); + } + }); + //filterInverse does the opposite. It removes the element from the list if the Predicate returns true //select and selectRejected work the same way except that they do not remove elements from the given collection and return a new collection