Допустим, у меня есть следующий класс с именем Employee
и список этих Employee
-классов:
class Employee {
private String praefix;
private String middleFix;
private String postfix;
private String name;
public Employee(String praefix, String middleFix, String postfix, String name) {
this.praefix = praefix;
this.middleFix = middleFix;
this.postfix = postfix;
this.name = name;
}
public String getPraefix() {
return praefix;
}
public void setPraefix(String praefix) {
this.praefix = praefix;
}
public String getMiddleFix() {
return middleFix;
}
public void setMiddleFix(String middleFix) {
this.middleFix = middleFix;
}
public String getPostfix() {
return postfix;
}
public void setPostfix(String postfix) {
this.postfix = postfix;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
List<Employee> employees = new ArrayList<>();
employees.add(new Employee("A", "B", "C", "Michael Phelps"));
employees.add(new Employee("A", "B", "C", "Cristiano Ronaldo"));
employees.add(new Employee("D", "E", "F", "Usain Bolton"));
employees.add(new Employee("D", "E", "F", "Diego Armando Maradona"));
employees.add(new Employee("D", "E", "F", "Lionel Messi"));
Возможно ли преобразовать его в следующую карту с помощью Java Stream-API?
{A.B.C=[Cristiano Ronaldo, Michael Phelps], D.E.F=[Aydin Korkmaz, Diego Armando Maradona, Usain Bolton]}