|
|
@@ -4,10 +4,7 @@ import com.zipcodewilmington.streams.tools.ReflectionUtils;
|
|
4
|
4
|
import com.zipcodewilmington.streams.tools.logging.LoggerHandler;
|
|
5
|
5
|
import com.zipcodewilmington.streams.tools.logging.LoggerWarehouse;
|
|
6
|
6
|
|
|
7
|
|
-import java.util.ArrayList;
|
|
8
|
|
-import java.util.Iterator;
|
|
9
|
|
-import java.util.List;
|
|
10
|
|
-import java.util.Map;
|
|
|
7
|
+import java.util.*;
|
|
11
|
8
|
import java.util.stream.Collectors;
|
|
12
|
9
|
import java.util.stream.Stream;
|
|
13
|
10
|
|
|
|
@@ -36,7 +33,8 @@ public final class PersonWarehouse implements Iterable<Person> {
|
|
36
|
33
|
* @return list of names of Person objects
|
|
37
|
34
|
*/ // TODO
|
|
38
|
35
|
public List<String> getNames() {
|
|
39
|
|
- return null;
|
|
|
36
|
+
|
|
|
37
|
+ return people.stream().map(Person::getName).collect(Collectors.toList());
|
|
40
|
38
|
}
|
|
41
|
39
|
|
|
42
|
40
|
|
|
|
@@ -44,7 +42,10 @@ public final class PersonWarehouse implements Iterable<Person> {
|
|
44
|
42
|
* @return list of uniquely named Person objects
|
|
45
|
43
|
*/ //TODO
|
|
46
|
44
|
public Stream<Person> getUniquelyNamedPeople() {
|
|
47
|
|
- return null;
|
|
|
45
|
+// Set<String> nameSet = people.stream().map(Person::getName).collect(Collectors.toSet());
|
|
|
46
|
+
|
|
|
47
|
+
|
|
|
48
|
+ return people.stream().distinct();
|
|
48
|
49
|
}
|
|
49
|
50
|
|
|
50
|
51
|
|
|
|
@@ -53,7 +54,9 @@ public final class PersonWarehouse implements Iterable<Person> {
|
|
53
|
54
|
* @return a Stream of respective
|
|
54
|
55
|
*/ //TODO
|
|
55
|
56
|
public Stream<Person> getUniquelyNamedPeopleStartingWith(Character character) {
|
|
56
|
|
- return null;
|
|
|
57
|
+
|
|
|
58
|
+ return people.stream()
|
|
|
59
|
+ .filter( -> );
|
|
57
|
60
|
}
|
|
58
|
61
|
|
|
59
|
62
|
/**
|