Skip to content

Commit

Permalink
Merge pull request eugenp#2230 from eugenp/BAEL-965-removing-lambda
Browse files Browse the repository at this point in the history
BAEL-965 - reverting to anonymous classes
  • Loading branch information
slavisa-baeldung authored Jul 8, 2017
2 parents c598b93 + 94ee35b commit edda728
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ public void givenTwoSortedLists_whenCollated_thenSorted() {

@Test
public void givenListOfCustomers_whenTransformed_thenListOfAddress() {
Collection<Address> addressCol = CollectionUtils.collect(list1, customer -> {
return new Address(customer.getLocality(), customer.getCity(), customer.getZip());
Collection<Address> addressCol = CollectionUtils.collect(list1, new Transformer<Customer, Address>() {
public Address transform(Customer customer) {
return new Address(customer.getLocality(), customer.getCity(), customer.getZip());
}
});

List<Address> addressList = new ArrayList<>(addressCol);
Expand All @@ -65,9 +67,13 @@ public void givenListOfCustomers_whenTransformed_thenListOfAddress() {

@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<Customer>() {
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

Expand Down

0 comments on commit edda728

Please sign in to comment.