inner interface examples added (#3151)

This commit is contained in:
bahti
2017-12-11 20:31:52 +03:00
committed by Grzegorz Piwowarek
parent 9046955197
commit b2ea831d83
3 changed files with 58 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
package com.baeldung.interfaces;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class CommaSeparatedCustomers implements Customer.List {
private List<Customer> customers = new ArrayList<Customer>();
@Override
public void Add(Customer customer) {
customers.add(customer);
}
@Override
public String getCustomerNames() {
return customers.stream().map(customer -> customer.getName()).collect(Collectors.joining(","));
}
}

View File

@@ -0,0 +1,19 @@
package com.baeldung.interfaces;
public class Customer {
public interface List {
void Add(Customer customer);
String getCustomerNames();
}
private String name;
public Customer(String name) {
this.name = name;
}
String getName() {
return name;
}
}