#27 Nick Satinover - Completed

Öppen
nsatinover vill sammanfoga 6 incheckningar från s[2]s in i master

+ 1
- 0
.idea/.name Visa fil

@@ -0,0 +1 @@
1
+looptest

+ 2
- 2
.idea/compiler.xml Visa fil

@@ -9,8 +9,8 @@
9 9
         <module name="looptest" />
10 10
       </profile>
11 11
     </annotationProcessing>
12
-    <bytecodeTargetLevel target="1.8">
13
-      <module name="looptest" target="1.8" />
12
+    <bytecodeTargetLevel>
13
+      <module name="looptest" target="8" />
14 14
     </bytecodeTargetLevel>
15 15
   </component>
16 16
 </project>

+ 0
- 7
.idea/kotlinc.xml Visa fil

@@ -1,7 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<project version="4">
3
-  <component name="KotlinCommonCompilerArguments">
4
-    <option name="languageVersion" value="1.1" />
5
-    <option name="apiVersion" value="1.1" />
6
-  </component>
7
-</project>

+ 1
- 35
.idea/misc.xml Visa fil

@@ -1,23 +1,5 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <project version="4">
3
-  <component name="JavadocGenerationManager">
4
-    <option name="OUTPUT_DIRECTORY" value="$PROJECT_DIR$/target" />
5
-    <option name="OPTION_SCOPE" value="protected" />
6
-    <option name="OPTION_HIERARCHY" value="true" />
7
-    <option name="OPTION_NAVIGATOR" value="true" />
8
-    <option name="OPTION_INDEX" value="true" />
9
-    <option name="OPTION_SEPARATE_INDEX" value="true" />
10
-    <option name="OPTION_DOCUMENT_TAG_USE" value="false" />
11
-    <option name="OPTION_DOCUMENT_TAG_AUTHOR" value="false" />
12
-    <option name="OPTION_DOCUMENT_TAG_VERSION" value="false" />
13
-    <option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="true" />
14
-    <option name="OPTION_DEPRECATED_LIST" value="true" />
15
-    <option name="OTHER_OPTIONS" />
16
-    <option name="HEAP_SIZE" />
17
-    <option name="LOCALE" />
18
-    <option name="OPEN_IN_BROWSER" value="true" />
19
-    <option name="OPTION_INCLUDE_LIBS" value="false" />
20
-  </component>
21 3
   <component name="MavenProjectsManager">
22 4
     <option name="originalFiles">
23 5
       <list>
@@ -25,23 +7,7 @@
25 7
       </list>
26 8
     </option>
27 9
   </component>
28
-  <component name="ProjectInspectionProfilesVisibleTreeState">
29
-    <entry key="Project Default">
30
-      <profile-state>
31
-        <expanded-state>
32
-          <State>
33
-            <id />
34
-          </State>
35
-        </expanded-state>
36
-        <selected-state>
37
-          <State>
38
-            <id>Android</id>
39
-          </State>
40
-        </selected-state>
41
-      </profile-state>
42
-    </entry>
43
-  </component>
44 10
   <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
45
-    <output url="file://$PROJECT_DIR$/out" />
11
+    <output url="file://$PROJECT_DIR$/classes" />
46 12
   </component>
47 13
 </project>

+ 1
- 1
.idea/modules.xml Visa fil

@@ -2,7 +2,7 @@
2 2
 <project version="4">
3 3
   <component name="ProjectModuleManager">
4 4
     <modules>
5
-      <module fileurl="file://$PROJECT_DIR$/streamdemo.iml" filepath="$PROJECT_DIR$/streamdemo.iml" />
5
+      <module fileurl="file://$PROJECT_DIR$/looptest.iml" filepath="$PROJECT_DIR$/looptest.iml" />
6 6
     </modules>
7 7
   </component>
8 8
 </project>

+ 0
- 124
.idea/uiDesigner.xml Visa fil

@@ -1,124 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<project version="4">
3
-  <component name="Palette2">
4
-    <group name="Swing">
5
-      <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
6
-        <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
7
-      </item>
8
-      <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
9
-        <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
10
-      </item>
11
-      <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
12
-        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
13
-      </item>
14
-      <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
15
-        <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
16
-      </item>
17
-      <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
18
-        <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
19
-        <initial-values>
20
-          <property name="text" value="Button" />
21
-        </initial-values>
22
-      </item>
23
-      <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
24
-        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
25
-        <initial-values>
26
-          <property name="text" value="RadioButton" />
27
-        </initial-values>
28
-      </item>
29
-      <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
30
-        <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
31
-        <initial-values>
32
-          <property name="text" value="CheckBox" />
33
-        </initial-values>
34
-      </item>
35
-      <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
36
-        <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
37
-        <initial-values>
38
-          <property name="text" value="Label" />
39
-        </initial-values>
40
-      </item>
41
-      <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
42
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
43
-          <preferred-size width="150" height="-1" />
44
-        </default-constraints>
45
-      </item>
46
-      <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
47
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
48
-          <preferred-size width="150" height="-1" />
49
-        </default-constraints>
50
-      </item>
51
-      <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
52
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
53
-          <preferred-size width="150" height="-1" />
54
-        </default-constraints>
55
-      </item>
56
-      <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
57
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
58
-          <preferred-size width="150" height="50" />
59
-        </default-constraints>
60
-      </item>
61
-      <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
62
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
63
-          <preferred-size width="150" height="50" />
64
-        </default-constraints>
65
-      </item>
66
-      <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
67
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
68
-          <preferred-size width="150" height="50" />
69
-        </default-constraints>
70
-      </item>
71
-      <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
72
-        <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
73
-      </item>
74
-      <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
75
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
76
-          <preferred-size width="150" height="50" />
77
-        </default-constraints>
78
-      </item>
79
-      <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
80
-        <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
81
-          <preferred-size width="150" height="50" />
82
-        </default-constraints>
83
-      </item>
84
-      <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
85
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
86
-          <preferred-size width="150" height="50" />
87
-        </default-constraints>
88
-      </item>
89
-      <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
90
-        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
91
-          <preferred-size width="200" height="200" />
92
-        </default-constraints>
93
-      </item>
94
-      <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
95
-        <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
96
-          <preferred-size width="200" height="200" />
97
-        </default-constraints>
98
-      </item>
99
-      <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
100
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
101
-      </item>
102
-      <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
103
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
104
-      </item>
105
-      <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
106
-        <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
107
-      </item>
108
-      <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
109
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
110
-      </item>
111
-      <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
112
-        <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
113
-          <preferred-size width="-1" height="20" />
114
-        </default-constraints>
115
-      </item>
116
-      <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
117
-        <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
118
-      </item>
119
-      <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
120
-        <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
121
-      </item>
122
-    </group>
123
-  </component>
124
-</project>

+ 411
- 1240
.idea/workspace.xml
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 16
- 0
looptest.iml Visa fil

@@ -0,0 +1,16 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
4
+    <output url="file://$MODULE_DIR$/target/classes" />
5
+    <output-test url="file://$MODULE_DIR$/target/test-classes" />
6
+    <content url="file://$MODULE_DIR$">
7
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
8
+      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
9
+      <excludeFolder url="file://$MODULE_DIR$/target" />
10
+    </content>
11
+    <orderEntry type="inheritedJdk" />
12
+    <orderEntry type="sourceFolder" forTests="false" />
13
+    <orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
14
+    <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
15
+  </component>
16
+</module>

+ 12
- 0
pom.xml Visa fil

@@ -7,6 +7,18 @@
7 7
     <groupId>mygroupid</groupId>
8 8
     <artifactId>looptest</artifactId>
9 9
     <version>1.0-SNAPSHOT</version>
10
+    <build>
11
+        <plugins>
12
+            <plugin>
13
+                <groupId>org.apache.maven.plugins</groupId>
14
+                <artifactId>maven-compiler-plugin</artifactId>
15
+                <configuration>
16
+                    <source>8</source>
17
+                    <target>8</target>
18
+                </configuration>
19
+            </plugin>
20
+        </plugins>
21
+    </build>
10 22
     <dependencies>
11 23
         <dependency>
12 24
             <groupId>junit</groupId>

+ 27
- 7
src/main/java/com/zipcodewilmington/streams/StreamFilter.java Visa fil

@@ -5,7 +5,9 @@ import com.zipcodewilmington.streams.anthropoid.PersonFactory;
5 5
 import com.zipcodewilmington.streams.tools.RandomUtils;
6 6
 import com.zipcodewilmington.streams.tools.StringUtils;
7 7
 
8
+import java.util.Arrays;
8 9
 import java.util.List;
10
+import java.util.function.Predicate;
9 11
 import java.util.stream.Collectors;
10 12
 import java.util.stream.Stream;
11 13
 
@@ -20,7 +22,7 @@ public class StreamFilter {
20 22
      * No arg constructor
21 23
      */ //TODO - construct person stream of 100 person objects; startingCharacter is a random capital letter
22 24
     public StreamFilter() {
23
-        this(Stream.empty(), null);
25
+        this(PersonFactory.createPersonStream(100), RandomUtils.createCharacter('A', 'Z'));
24 26
     }
25 27
 
26 28
     /**
@@ -28,7 +30,8 @@ public class StreamFilter {
28 30
      * @param startingCharacter - character to filter by
29 31
      */ //TODO
30 32
     public StreamFilter(Person[] people, Character startingCharacter) {
31
-        this(Stream.empty(), null);
33
+        this(Arrays.stream(people),startingCharacter);
34
+        //Arrays.stream(people).filter(person -> person.getName().startsWith(startingCharacter.toString()));
32 35
     }
33 36
 
34 37
     /**
@@ -36,7 +39,8 @@ public class StreamFilter {
36 39
      * @param startingCharacter - character to filter by
37 40
      */ //TODO
38 41
     public StreamFilter(List<Person> people, Character startingCharacter) {
39
-        this(Stream.empty(), null);
42
+        this(people.stream(), startingCharacter);
43
+        // people.stream().filter(person -> person.getName().startsWith(startingCharacter.toString()));
40 44
     }
41 45
 
42 46
 
@@ -55,7 +59,12 @@ public class StreamFilter {
55 59
      * @return a list of person object whose name starts with `this.startingCharacter`
56 60
      */ //TODO
57 61
     public List<Person> toListMultiLine() {
58
-        return null;
62
+//        Predicate<Person> personPredicate = person -> person.getName().startsWith(startingCharacter);
63
+//        return personStream.filter(personPredicate).collect(Collectors.toList());
64
+        Predicate<Person> filter = person -> StringUtils.isPalindromeIgnoreCase(person.name);
65
+        return personStream
66
+                .filter(filter)
67
+                .collect(Collectors.toList());
59 68
     }
60 69
 
61 70
 
@@ -64,7 +73,10 @@ public class StreamFilter {
64 73
      * @return a list of person objects whose name starts with `this.startingCharacter`
65 74
      */ //TODO
66 75
     public List<Person> toListOneLine() {
67
-        return null;
76
+        // return personStream.filter(person -> person.getName().startsWith(startingCharacter)).collect(Collectors.toList());
77
+        return personStream
78
+                .filter(person -> StringUtils.isPalindromeIgnoreCase(person.name))
79
+                .collect(Collectors.toList());
68 80
     }
69 81
 
70 82
 
@@ -73,7 +85,10 @@ public class StreamFilter {
73 85
      * @return an array of person object whose name starts with `this.startingCharacter`
74 86
      */ //TODO
75 87
     public Person[] toArrayOneLine() {
76
-        return null;
88
+       // return personStream.filter(person -> person.getName().startsWith(startingCharacter)).toArray(Person[]::new);
89
+        return personStream
90
+                .filter(person -> StringUtils.isPalindromeIgnoreCase(person.name))
91
+                .toArray(Person[]::new);
77 92
     }
78 93
 
79 94
 
@@ -82,7 +97,12 @@ public class StreamFilter {
82 97
      * @return an array of person object whose name starts with `this.startingCharacter`
83 98
      */ //TODO
84 99
     public Person[] toArrayMultiLine() {
85
-        return null;
100
+//        Predicate<Person> personPredicate = person -> person.getName().startsWith(startingCharacter);
101
+//        return personStream.filter(personPredicate).toArray(Person[]::new);
102
+        Predicate<Person> filter = person -> StringUtils.isPalindromeIgnoreCase(person.name);
103
+        return personStream
104
+                .filter(filter)
105
+                .toArray(Person[]::new);
86 106
     }
87 107
 
88 108
 }

+ 4
- 3
src/main/java/com/zipcodewilmington/streams/StreamMap.java Visa fil

@@ -5,6 +5,7 @@ import com.zipcodewilmington.streams.conversions.StreamConverter;
5 5
 
6 6
 import java.util.Arrays;
7 7
 import java.util.List;
8
+import java.util.regex.Pattern;
8 9
 import java.util.stream.Collectors;
9 10
 import java.util.stream.Stream;
10 11
 
@@ -18,7 +19,7 @@ public class StreamMap {
18 19
      * @return - a Stream of single characters
19 20
      */ //TODO
20 21
     public static Stream<String> letters(String someWord) {
21
-        return null;
22
+        return Pattern.compile("").splitAsStream(someWord);
22 23
     }
23 24
 
24 25
     /**
@@ -26,7 +27,7 @@ public class StreamMap {
26 27
      * @return - a Stream of several Streams of single characters
27 28
      */ //TODO
28 29
     public static Stream<Stream<String>> wordsMap(String... someWords) {
29
-        return null;
30
+        return Arrays.stream(someWords).map(StreamMap::letters);
30 31
     }
31 32
 
32 33
     /**
@@ -34,6 +35,6 @@ public class StreamMap {
34 35
      * @return - a Stream of several Streams of single characters
35 36
      */ //TODO
36 37
     public static Stream<String> wordsFlatMap(String... stringArray) {
37
-        return null;
38
+        return Arrays.stream(stringArray).flatMap(StreamMap::letters);
38 39
     }
39 40
 }

+ 11
- 3
src/main/java/com/zipcodewilmington/streams/anthropoid/PersonFactory.java Visa fil

@@ -3,6 +3,7 @@ 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.Arrays;
6 7
 import java.util.Date;
7 8
 import java.util.List;
8 9
 import java.util.stream.Collectors;
@@ -39,7 +40,10 @@ public final class PersonFactory {
39 40
      * @return - ArrayList of Person objects
40 41
      */ // TODO
41 42
     public static List<Person> createPersonList(int listSize) {
42
-        return null;
43
+//        List<Person> personList = createPersonStream(listSize).collect(Collectors.toList());
44
+//        return personList;
45
+        return createPersonStream(listSize)
46
+                .collect(Collectors.toList());
43 47
     }
44 48
 
45 49
 
@@ -48,7 +52,10 @@ public final class PersonFactory {
48 52
      * @return - Array of Person objects
49 53
      */ // TODO
50 54
     public static Person[] createPersonArray(int arrayLength) {
51
-        return null;
55
+//        Person[] person = createPersonStream(arrayLength).toArray(Person[]::new);
56
+//        return person;
57
+        return createPersonStream(arrayLength)
58
+                .toArray(Person[]::new);
52 59
     }
53 60
 
54 61
 
@@ -58,6 +65,7 @@ public final class PersonFactory {
58 65
      * @return - Stream representation of collection of Person objects
59 66
      */ // TODO
60 67
     public static Stream<Person> createPersonStream(int streamCount) {
61
-        return null;
68
+        return Stream.generate(PersonFactory::createRandomPerson)
69
+                .limit(streamCount);
62 70
     }
63 71
 }

+ 11
- 10
src/main/java/com/zipcodewilmington/streams/anthropoid/PersonWarehouse.java Visa fil

@@ -4,12 +4,13 @@ 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.List;
9
-import java.util.Map;
7
+import java.util.*;
10 8
 import java.util.stream.Collectors;
11 9
 import java.util.stream.Stream;
12 10
 
11
+import static java.util.stream.Collectors.toConcurrentMap;
12
+import static java.util.stream.Collectors.toMap;
13
+
13 14
 /**
14 15
  * Created by leon on 5/29/17.
15 16
  * The warehouse is responsible for storing, retrieving, and filtering personSequence
@@ -35,7 +36,7 @@ public final class PersonWarehouse {
35 36
      * @return list of uniquely named Person objects
36 37
      */ //TODO
37 38
     public static Stream<Person> getUniquelyNamedPeople() {
38
-        return null;
39
+        return people.stream().distinct();
39 40
     }
40 41
 
41 42
 
@@ -44,7 +45,7 @@ public final class PersonWarehouse {
44 45
      * @return a Stream of respective
45 46
      */ //TODO
46 47
     public static Stream<Person> getUniquelyNamedPeopleStartingWith(Character character) {
47
-        return null;
48
+        return getUniquelyNamedPeople().filter(person -> person.getName().charAt(0) == character);
48 49
     }
49 50
 
50 51
     /**
@@ -52,14 +53,14 @@ public final class PersonWarehouse {
52 53
      * @return a Stream of respective
53 54
      */ //TODO
54 55
     public static Stream<Person> getFirstNUniquelyNamedPeople(int n) {
55
-        return null;
56
+        return getUniquelyNamedPeople().limit(n);
56 57
     }
57 58
 
58 59
     /**
59 60
      * @return a mapping of Person Id to the respective Person name
60 61
      */ // TODO
61 62
     public static Map<Long, String> getIdToNameMap() {
62
-        return null;
63
+        return people.stream().collect(Collectors.toMap(Person::getPersonalId, Person::getName));
63 64
     }
64 65
 
65 66
 
@@ -67,7 +68,7 @@ public final class PersonWarehouse {
67 68
      * @return Stream of Stream of Aliases
68 69
      */ // TODO
69 70
     public static Stream<Stream<String>> getNestedAliases() {
70
-        return null;
71
+        return people.stream().map(p -> Stream.of(p.getAliases()));
71 72
     }
72 73
 
73 74
 
@@ -75,14 +76,14 @@ public final class PersonWarehouse {
75 76
      * @return Stream of all Aliases
76 77
      */ // TODO
77 78
     public static Stream<String> getAllAliases() {
78
-        return null;
79
+        return people.stream().flatMap(p -> Stream.of(p.getAliases()));
79 80
     }
80 81
 
81 82
     /**
82 83
      * @return list of names of Person objects
83 84
      */ // TODO
84 85
     public static List<String> getNames() {
85
-        return null;
86
+        return people.stream().map(Person::getName).collect(Collectors.toList());
86 87
     }
87 88
 
88 89
     /**

+ 3
- 2
src/main/java/com/zipcodewilmington/streams/conversions/ArrayConverter.java Visa fil

@@ -5,6 +5,7 @@ import com.zipcodewilmington.streams.anthropoid.PersonFactory;
5 5
 
6 6
 import java.util.Arrays;
7 7
 import java.util.List;
8
+import java.util.stream.Collectors;
8 9
 import java.util.stream.Stream;
9 10
 
10 11
 /**
@@ -23,12 +24,12 @@ public final class ArrayConverter extends PersonConversionAgent<Person[]> {
23 24
 
24 25
     //TODO
25 26
     public List<Person> toList() {
26
-        return null;
27
+        return Arrays.stream(super.objectSequence).collect(Collectors.toList());
27 28
     }
28 29
 
29 30
     //TODO
30 31
     public Stream<Person> toStream() {
31
-        return null;
32
+        return Stream.of(super.objectSequence);
32 33
     }
33 34
 
34 35
     @Override

+ 2
- 2
src/main/java/com/zipcodewilmington/streams/conversions/ListConverter.java Visa fil

@@ -27,11 +27,11 @@ public final class ListConverter extends PersonConversionAgent<List<Person>> {
27 27
 
28 28
     //TODO
29 29
     public Stream<Person> toStream() {
30
-        return null;
30
+        return super.objectSequence.stream();
31 31
     }
32 32
 
33 33
     //TODO
34 34
     public Person[] toArray() {
35
-        return null;
35
+        return super.objectSequence.stream().toArray(Person[]::new);
36 36
     }
37 37
 }

+ 3
- 3
src/main/java/com/zipcodewilmington/streams/conversions/StreamConverter.java Visa fil

@@ -25,16 +25,16 @@ public final class StreamConverter extends PersonConversionAgent<Stream<Person>>
25 25
 
26 26
     // TODO
27 27
     public List<Person> toList() {
28
-        return null;
28
+        return personList;
29 29
     }
30 30
 
31 31
     // TODO
32 32
     public Stream<Person> toStream() {
33
-        return null;
33
+        return personList.stream();
34 34
     }
35 35
 
36 36
     // TODO
37 37
     public Person[] toArray() {
38
-        return null;
38
+        return personList.stream().toArray(Person[]::new);
39 39
     }
40 40
 }

+ 850394
- 6
target/PersonWarehouse.leonlog
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


Binär
target/classes/com/zipcodewilmington/streams/StreamFilter.class Visa fil


Binär
target/classes/com/zipcodewilmington/streams/anthropoid/PersonFactory.class Visa fil


Binär
target/classes/com/zipcodewilmington/streams/anthropoid/PersonWarehouse.class Visa fil


+ 1
- 1
target/global.leonlog Visa fil

@@ -1,2 +1,2 @@
1
-May 31, 2017 4:45:59 PM com.zipcodewilmington.streams.tools.logging.LoggerHandler log
1
+Nov 25, 2018 9:29:22 PM com.zipcodewilmington.streams.tools.logging.LoggerHandler log
2 2
 INFO: Instantiating logger for [ com.zipcodewilmington.streams.anthropoid.PersonWarehouse ] ... 

Binär
target/test-classes/com/zipcodewilmington/streams/TestStreamMap.class Visa fil