#33 First PR

开启中
natehalldev 请求将 1 次代码提交从 natehalldev/CR-MicroLabs-Streams-And-Lambdas:master 合并至 master

+ 12
- 3
src/main/java/com/zipcodewilmington/streams/anthropoid/PersonFactory.java 查看文件

@@ -3,6 +3,8 @@ package com.zipcodewilmington.streams.anthropoid;
3 3
 import com.zipcodewilmington.streams.tools.RandomUtils;
4 4
 import com.zipcodewilmington.streams.tools.StringUtils;
5 5
 
6
+import java.util.ArrayList;
7
+import java.util.Arrays;
6 8
 import java.util.Date;
7 9
 import java.util.List;
8 10
 import java.util.stream.Collectors;
@@ -39,7 +41,10 @@ public final class PersonFactory {
39 41
      * @return - ArrayList of Person objects
40 42
      */ // TODO
41 43
     public List<Person> createPersonList(int listSize) {
42
-        return null;
44
+
45
+
46
+
47
+        return Arrays.asList(createPersonArray(listSize));
43 48
     }
44 49
 
45 50
 
@@ -48,7 +53,8 @@ public final class PersonFactory {
48 53
      * @return - Array of Person objects
49 54
      */ // TODO
50 55
     public Person[] createPersonArray(int arrayLength) {
51
-        return null;
56
+
57
+        return createPersonStream(arrayLength).toArray(size -> new Person[arrayLength]);
52 58
     }
53 59
 
54 60
 
@@ -59,6 +65,9 @@ public final class PersonFactory {
59 65
      * @return - Stream representation of collection of Person objects
60 66
      */ // TODO
61 67
     public Stream<Person> createPersonStream(int streamCount) {
62
-        return null;
68
+
69
+
70
+        return Stream.generate(() -> createRandomPerson())
71
+                .limit(streamCount);
63 72
     }
64 73
 }

+ 10
- 7
src/main/java/com/zipcodewilmington/streams/anthropoid/PersonWarehouse.java 查看文件

@@ -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
     /**