public List<Customer> getFiltered(List<Customer> allCustomers)
{
List<Customer> filteredCustomers = new ArrayList<Customer>
for(Customer customer : allCustomers)
{
if(customer.getWhatever() == ???)
{
filteredCustomers.add(customer);
}
}
return filteredCustomers;
}
public interface Filter<T> {
public boolean matches(T t);
}
public List<Customer> getFiltered(List<Customer> allCustomers, Filter<Customer> filter) {
List<Customer> filteredCustomers = new ArrayList<Customer>();
for(Customer customer : allCustomers) {
if(filter.matches(customer)) {
filteredCustomers.add(customer);
}
}
return filteredCustomers;
}
Hab mal kurz Ariol's Code debuggt
public List<Customer> getFiltered(List<Customer> allCustomers)
{
List<Customer> filteredCustomers = new ArrayList<Customer>();
for(Customer customer : allCustomers)
{
if(customer.getWhatever() == ???)
{
filteredCustomers.add(customer);
}
}
return filteredCustomers;
}