CHU1TA26 6 jaren geleden
bovenliggende
commit
947cf05db6
35 gewijzigde bestanden met toevoegingen van 850902 en 1473 verwijderingen
  1. 1
    0
      .idea/.name
  2. 2
    2
      .idea/compiler.xml
  3. 0
    7
      .idea/kotlinc.xml
  4. 2
    36
      .idea/misc.xml
  5. 1
    1
      .idea/modules.xml
  6. 0
    124
      .idea/uiDesigner.xml
  7. 376
    1263
      .idea/workspace.xml
  8. 16
    0
      looptest.iml
  9. 12
    0
      pom.xml
  10. 40
    7
      src/main/java/com/zipcodewilmington/streams/StreamFilter.java
  11. 10
    4
      src/main/java/com/zipcodewilmington/streams/StreamMap.java
  12. 10
    3
      src/main/java/com/zipcodewilmington/streams/anthropoid/PersonFactory.java
  13. 19
    10
      src/main/java/com/zipcodewilmington/streams/anthropoid/PersonWarehouse.java
  14. 6
    3
      src/main/java/com/zipcodewilmington/streams/conversions/ArrayConverter.java
  15. 6
    2
      src/main/java/com/zipcodewilmington/streams/conversions/ListConverter.java
  16. 5
    3
      src/main/java/com/zipcodewilmington/streams/conversions/StreamConverter.java
  17. 1
    1
      streamdemo.iml
  18. 850394
    6
      target/PersonWarehouse.leonlog
  19. BIN
      target/classes/com/zipcodewilmington/streams/StreamFilter.class
  20. BIN
      target/classes/com/zipcodewilmington/streams/StreamMap.class
  21. BIN
      target/classes/com/zipcodewilmington/streams/anthropoid/PersonFactory.class
  22. BIN
      target/classes/com/zipcodewilmington/streams/anthropoid/PersonWarehouse.class
  23. BIN
      target/classes/com/zipcodewilmington/streams/conversions/ArrayConverter.class
  24. BIN
      target/classes/com/zipcodewilmington/streams/conversions/ListConverter.class
  25. BIN
      target/classes/com/zipcodewilmington/streams/conversions/StreamConverter.class
  26. BIN
      target/classes/com/zipcodewilmington/streams/tools/RandomUtils.class
  27. BIN
      target/classes/com/zipcodewilmington/streams/tools/ReflectionUtils$1.class
  28. BIN
      target/classes/com/zipcodewilmington/streams/tools/ReflectionUtils.class
  29. BIN
      target/classes/com/zipcodewilmington/streams/tools/StringUtils.class
  30. BIN
      target/classes/com/zipcodewilmington/streams/tools/logging/LoggerHandler.class
  31. 1
    1
      target/global.leonlog
  32. BIN
      target/test-classes/com/zipcodewilmington/streams/TestStreamFilter.class
  33. BIN
      target/test-classes/com/zipcodewilmington/streams/TestStreamMap.class
  34. BIN
      target/test-classes/com/zipcodewilmington/streams/anthropoid/TestPerson.class
  35. BIN
      target/test-classes/com/zipcodewilmington/streams/conversions/TestConversionAgent.class

+ 1
- 0
.idea/.name Bestand weergeven

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

+ 2
- 2
.idea/compiler.xml Bestand weergeven

@@ -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 Bestand weergeven

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

+ 2
- 36
.idea/misc.xml Bestand weergeven

@@ -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
-  <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" />
10
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
11
+    <output url="file://$PROJECT_DIR$/classes" />
46 12
   </component>
47 13
 </project>

+ 1
- 1
.idea/modules.xml Bestand weergeven

@@ -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 Bestand weergeven

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

+ 376
- 1263
.idea/workspace.xml
Diff onderdrukt omdat het te groot bestand
Bestand weergeven


+ 16
- 0
looptest.iml Bestand weergeven

@@ -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 Bestand weergeven

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

+ 40
- 7
src/main/java/com/zipcodewilmington/streams/StreamFilter.java Bestand weergeven

@@ -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,8 @@ 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
+
26
+        this(PersonFactory.createPersonStream(100), RandomUtils.createCharacter('A','Z'));
24 27
     }
25 28
 
26 29
     /**
@@ -28,7 +31,8 @@ public class StreamFilter {
28 31
      * @param startingCharacter - character to filter by
29 32
      */ //TODO
30 33
     public StreamFilter(Person[] people, Character startingCharacter) {
31
-        this(Stream.empty(), null);
34
+
35
+        this(Stream.of(people), startingCharacter);
32 36
     }
33 37
 
34 38
     /**
@@ -36,7 +40,7 @@ public class StreamFilter {
36 40
      * @param startingCharacter - character to filter by
37 41
      */ //TODO
38 42
     public StreamFilter(List<Person> people, Character startingCharacter) {
39
-        this(Stream.empty(), null);
43
+        this(people.stream(), startingCharacter);
40 44
     }
41 45
 
42 46
 
@@ -55,7 +59,27 @@ 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
+       return personStream.
63
+                filter(
64
+                        person ->
65
+                                person.getName()
66
+                                        .equalsIgnoreCase(startingCharacter))
67
+                .collect(Collectors.toList());
68
+
69
+        // Predicate<Person> personPredicate=
70
+
71
+//                        //StringUtils
72
+//                                .isPalindromeIgnoreCase
73
+//                                        (person.
74
+//                                                getName());
75
+//       return personStream
76
+//               .filter(personPredicate)
77
+//               .collect(
78
+//                       Collectors
79
+//                               .toList());
80
+
81
+
82
+
59 83
     }
60 84
 
61 85
 
@@ -64,7 +88,10 @@ public class StreamFilter {
64 88
      * @return a list of person objects whose name starts with `this.startingCharacter`
65 89
      */ //TODO
66 90
     public List<Person> toListOneLine() {
67
-        return null;
91
+        Predicate<Person> personPredicate= person -> StringUtils.isPalindromeIgnoreCase(person.getName());
92
+
93
+        return personStream.filter(personPredicate).collect(Collectors.toList());
94
+
68 95
     }
69 96
 
70 97
 
@@ -73,7 +100,8 @@ public class StreamFilter {
73 100
      * @return an array of person object whose name starts with `this.startingCharacter`
74 101
      */ //TODO
75 102
     public Person[] toArrayOneLine() {
76
-        return null;
103
+
104
+        return personStream.filter(person -> person.getName().equalsIgnoreCase(startingCharacter)).toArray(Person[]::new);
77 105
     }
78 106
 
79 107
 
@@ -82,7 +110,12 @@ public class StreamFilter {
82 110
      * @return an array of person object whose name starts with `this.startingCharacter`
83 111
      */ //TODO
84 112
     public Person[] toArrayMultiLine() {
85
-        return null;
113
+
114
+        return personStream.
115
+                filter(person ->
116
+                        person.getName()
117
+                                .equalsIgnoreCase(startingCharacter))
118
+                .toArray(Person[]::new);
86 119
     }
87 120
 
88 121
 }

+ 10
- 4
src/main/java/com/zipcodewilmington/streams/StreamMap.java Bestand weergeven

@@ -18,7 +18,11 @@ public class StreamMap {
18 18
      * @return - a Stream of single characters
19 19
      */ //TODO
20 20
     public static Stream<String> letters(String someWord) {
21
-        return null;
21
+       Stream <String> stringStream = someWord.codePoints()
22
+                .mapToObj(c -> String.valueOf((char) c) );
23
+       return stringStream;
24
+
25
+
22 26
     }
23 27
 
24 28
     /**
@@ -26,14 +30,16 @@ public class StreamMap {
26 30
      * @return - a Stream of several Streams of single characters
27 31
      */ //TODO
28 32
     public static Stream<Stream<String>> wordsMap(String... someWords) {
29
-        return null;
33
+
34
+        return Stream.of(someWords).map(c -> letters(c));
30 35
     }
31 36
 
32 37
     /**
33 38
      * @param stringArray - variable amount of String arguments
34 39
      * @return - a Stream of several Streams of single characters
35 40
      */ //TODO
36
-    public static Stream<String> wordsFlatMap(String... stringArray) {
37
-        return null;
41
+    public static Stream<String> wordsFlatMap(String... stringArray)
42
+    {
43
+        return Stream.of(stringArray).flatMap(c -> letters(c));
38 44
     }
39 45
 }

+ 10
- 3
src/main/java/com/zipcodewilmington/streams/anthropoid/PersonFactory.java Bestand weergeven

@@ -3,8 +3,10 @@ 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;
6 7
 import java.util.Date;
7 8
 import java.util.List;
9
+import java.util.Map;
8 10
 import java.util.stream.Collectors;
9 11
 import java.util.stream.Stream;
10 12
 
@@ -39,7 +41,9 @@ public final class PersonFactory {
39 41
      * @return - ArrayList of Person objects
40 42
      */ // TODO
41 43
     public static List<Person> createPersonList(int listSize) {
42
-        return null;
44
+
45
+
46
+        return  createPersonStream(listSize).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 [] people= new Person[arrayLength];
56
+
57
+
58
+        return createPersonList(arrayLength).toArray(people);
52 59
     }
53 60
 
54 61
 
@@ -58,6 +65,6 @@ 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(()->createRandomPerson()).limit(streamCount);
62 69
     }
63 70
 }

+ 19
- 10
src/main/java/com/zipcodewilmington/streams/anthropoid/PersonWarehouse.java Bestand weergeven

@@ -4,9 +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.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
 
@@ -35,7 +33,10 @@ public final class PersonWarehouse {
35 33
      * @return list of uniquely named Person objects
36 34
      */ //TODO
37 35
     public static Stream<Person> getUniquelyNamedPeople() {
38
-        return null;
36
+       return people.stream().distinct();
37
+
38
+
39
+
39 40
     }
40 41
 
41 42
 
@@ -44,7 +45,8 @@ 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
+
49
+        return getUniquelyNamedPeople().filter(person -> person.getName().startsWith(character.toString()));
48 50
     }
49 51
 
50 52
     /**
@@ -52,14 +54,17 @@ public final class PersonWarehouse {
52 54
      * @return a Stream of respective
53 55
      */ //TODO
54 56
     public static Stream<Person> getFirstNUniquelyNamedPeople(int n) {
55
-        return null;
57
+
58
+        return getUniquelyNamedPeople().limit(n);
56 59
     }
57 60
 
58 61
     /**
59 62
      * @return a mapping of Person Id to the respective Person name
60 63
      */ // TODO
61 64
     public static Map<Long, String> getIdToNameMap() {
62
-        return null;
65
+
66
+
67
+        return people.stream().collect(Collectors.toMap(Person::getPersonalId,Person::getName));
63 68
     }
64 69
 
65 70
 
@@ -67,7 +72,8 @@ public final class PersonWarehouse {
67 72
      * @return Stream of Stream of Aliases
68 73
      */ // TODO
69 74
     public static Stream<Stream<String>> getNestedAliases() {
70
-        return null;
75
+
76
+        return people.stream().map(person -> Stream.of(person.getAliases())) ;
71 77
     }
72 78
 
73 79
 
@@ -75,20 +81,23 @@ public final class PersonWarehouse {
75 81
      * @return Stream of all Aliases
76 82
      */ // TODO
77 83
     public static Stream<String> getAllAliases() {
78
-        return null;
84
+
85
+        return people.stream().flatMap(person -> Stream.of(person.aliases));
79 86
     }
80 87
 
81 88
     /**
82 89
      * @return list of names of Person objects
83 90
      */ // TODO
84 91
     public static List<String> getNames() {
85
-        return null;
92
+
93
+        return people.stream().map(Person::getName).collect(Collectors.toList());
86 94
     }
87 95
 
88 96
     /**
89 97
      * @return ArrayList of all Person objects in this warehouse
90 98
      */
91 99
     public static ArrayList<Person> getPeople() {
100
+
92 101
         return people;
93 102
     }
94 103
 

+ 6
- 3
src/main/java/com/zipcodewilmington/streams/conversions/ArrayConverter.java Bestand weergeven

@@ -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,16 +24,18 @@ 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
+
33
+        return Arrays.stream(super.objectSequence);
32 34
     }
33 35
 
34 36
     @Override
35 37
     public Person[] toArray() {
36
-        return super.objectSequence;
38
+        return
39
+                super.objectSequence;
37 40
     }
38 41
 }

+ 6
- 2
src/main/java/com/zipcodewilmington/streams/conversions/ListConverter.java Bestand weergeven

@@ -3,7 +3,9 @@ package com.zipcodewilmington.streams.conversions;
3 3
 import com.zipcodewilmington.streams.anthropoid.Person;
4 4
 import com.zipcodewilmington.streams.anthropoid.PersonFactory;
5 5
 
6
+import java.util.Arrays;
6 7
 import java.util.List;
8
+import java.util.stream.Collector;
7 9
 import java.util.stream.Stream;
8 10
 
9 11
 /**
@@ -27,11 +29,13 @@ public final class ListConverter extends PersonConversionAgent<List<Person>> {
27 29
 
28 30
     //TODO
29 31
     public Stream<Person> toStream() {
30
-        return null;
32
+
33
+        return super.objectSequence.stream();
31 34
     }
32 35
 
33 36
     //TODO
34 37
     public Person[] toArray() {
35
-        return null;
38
+
39
+        return super.objectSequence.stream().toArray(Person[]::new);
36 40
     }
37 41
 }

+ 5
- 3
src/main/java/com/zipcodewilmington/streams/conversions/StreamConverter.java Bestand weergeven

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

+ 1
- 1
streamdemo.iml Bestand weergeven

@@ -1,6 +1,6 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3
-  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
3
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
4 4
     <output url="file://$MODULE_DIR$/target/classes" />
5 5
     <output-test url="file://$MODULE_DIR$/target/test-classes" />
6 6
     <content url="file://$MODULE_DIR$">

+ 850394
- 6
target/PersonWarehouse.leonlog
Diff onderdrukt omdat het te groot bestand
Bestand weergeven


BIN
target/classes/com/zipcodewilmington/streams/StreamFilter.class Bestand weergeven


BIN
target/classes/com/zipcodewilmington/streams/StreamMap.class Bestand weergeven


BIN
target/classes/com/zipcodewilmington/streams/anthropoid/PersonFactory.class Bestand weergeven


BIN
target/classes/com/zipcodewilmington/streams/anthropoid/PersonWarehouse.class Bestand weergeven


BIN
target/classes/com/zipcodewilmington/streams/conversions/ArrayConverter.class Bestand weergeven


BIN
target/classes/com/zipcodewilmington/streams/conversions/ListConverter.class Bestand weergeven


BIN
target/classes/com/zipcodewilmington/streams/conversions/StreamConverter.class Bestand weergeven


BIN
target/classes/com/zipcodewilmington/streams/tools/RandomUtils.class Bestand weergeven


BIN
target/classes/com/zipcodewilmington/streams/tools/ReflectionUtils$1.class Bestand weergeven


BIN
target/classes/com/zipcodewilmington/streams/tools/ReflectionUtils.class Bestand weergeven


BIN
target/classes/com/zipcodewilmington/streams/tools/StringUtils.class Bestand weergeven


BIN
target/classes/com/zipcodewilmington/streams/tools/logging/LoggerHandler.class Bestand weergeven


+ 1
- 1
target/global.leonlog Bestand weergeven

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

BIN
target/test-classes/com/zipcodewilmington/streams/TestStreamFilter.class Bestand weergeven


BIN
target/test-classes/com/zipcodewilmington/streams/TestStreamMap.class Bestand weergeven


BIN
target/test-classes/com/zipcodewilmington/streams/anthropoid/TestPerson.class Bestand weergeven


BIN
target/test-classes/com/zipcodewilmington/streams/conversions/TestConversionAgent.class Bestand weergeven