Simran Bhutani 6 gadus atpakaļ
vecāks
revīzija
af9934b232
28 mainītis faili ar 84500 papildinājumiem un 1436 dzēšanām
  1. 1
    0
      .idea/.name
  2. 0
    3
      .idea/compiler.xml
  3. 0
    7
      .idea/kotlinc.xml
  4. 0
    13
      .idea/libraries/Maven__junit_junit_4_12.xml
  5. 0
    13
      .idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml
  6. 1
    34
      .idea/misc.xml
  7. 0
    8
      .idea/modules.xml
  8. 0
    124
      .idea/uiDesigner.xml
  9. 532
    1202
      .idea/workspace.xml
  10. 12
    0
      pom.xml
  11. 8
    7
      src/main/java/com/zipcodewilmington/streams/StreamFilter.java
  12. 3
    3
      src/main/java/com/zipcodewilmington/streams/StreamMap.java
  13. 4
    3
      src/main/java/com/zipcodewilmington/streams/anthropoid/PersonFactory.java
  14. 4
    4
      src/main/java/com/zipcodewilmington/streams/anthropoid/PersonWarehouse.java
  15. 3
    2
      src/main/java/com/zipcodewilmington/streams/conversions/ArrayConverter.java
  16. 4
    2
      src/main/java/com/zipcodewilmington/streams/conversions/ListConverter.java
  17. 3
    3
      src/main/java/com/zipcodewilmington/streams/conversions/StreamConverter.java
  18. 2
    1
      src/test/java/com/zipcodewilmington/streams/anthropoid/TestPersonWarehouse.java
  19. 83922
    6
      target/PersonWarehouse.leonlog
  20. Binārs
      target/classes/com/zipcodewilmington/streams/StreamFilter.class
  21. Binārs
      target/classes/com/zipcodewilmington/streams/StreamMap.class
  22. Binārs
      target/classes/com/zipcodewilmington/streams/anthropoid/PersonFactory.class
  23. Binārs
      target/classes/com/zipcodewilmington/streams/anthropoid/PersonWarehouse.class
  24. Binārs
      target/classes/com/zipcodewilmington/streams/conversions/ArrayConverter.class
  25. Binārs
      target/classes/com/zipcodewilmington/streams/conversions/ListConverter.class
  26. Binārs
      target/classes/com/zipcodewilmington/streams/conversions/StreamConverter.class
  27. 1
    1
      target/global.leonlog
  28. Binārs
      target/test-classes/com/zipcodewilmington/streams/TestStreamMap.class

+ 1
- 0
.idea/.name Parādīt failu

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

+ 0
- 3
.idea/compiler.xml Parādīt failu

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

+ 0
- 7
.idea/kotlinc.xml Parādīt failu

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

+ 0
- 13
.idea/libraries/Maven__junit_junit_4_12.xml Parādīt failu

@@ -1,13 +0,0 @@
1
-<component name="libraryTable">
2
-  <library name="Maven: junit:junit:4.12">
3
-    <CLASSES>
4
-      <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.12/junit-4.12.jar!/" />
5
-    </CLASSES>
6
-    <JAVADOC>
7
-      <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.12/junit-4.12-javadoc.jar!/" />
8
-    </JAVADOC>
9
-    <SOURCES>
10
-      <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.12/junit-4.12-sources.jar!/" />
11
-    </SOURCES>
12
-  </library>
13
-</component>

+ 0
- 13
.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml Parādīt failu

@@ -1,13 +0,0 @@
1
-<component name="libraryTable">
2
-  <library name="Maven: org.hamcrest:hamcrest-core:1.3">
3
-    <CLASSES>
4
-      <root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar!/" />
5
-    </CLASSES>
6
-    <JAVADOC>
7
-      <root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-javadoc.jar!/" />
8
-    </JAVADOC>
9
-    <SOURCES>
10
-      <root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar!/" />
11
-    </SOURCES>
12
-  </library>
13
-</component>

+ 1
- 34
.idea/misc.xml Parādīt failu

@@ -1,23 +1,6 @@
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>
3
+  <component name="ExternalStorageConfigurationManager" enabled="true" />
21 4
   <component name="MavenProjectsManager">
22 5
     <option name="originalFiles">
23 6
       <list>
@@ -25,22 +8,6 @@
25 8
       </list>
26 9
     </option>
27 10
   </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 11
   <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
45 12
     <output url="file://$PROJECT_DIR$/out" />
46 13
   </component>

+ 0
- 8
.idea/modules.xml Parādīt failu

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

+ 0
- 124
.idea/uiDesigner.xml Parādīt failu

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

+ 532
- 1202
.idea/workspace.xml
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


+ 12
- 0
pom.xml Parādīt failu

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

+ 8
- 7
src/main/java/com/zipcodewilmington/streams/StreamFilter.java Parādīt failu

@@ -5,6 +5,7 @@ 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;
9 10
 import java.util.stream.Collectors;
10 11
 import java.util.stream.Stream;
@@ -20,7 +21,7 @@ public class StreamFilter {
20 21
      * No arg constructor
21 22
      */ //TODO - construct person stream of 100 person objects; startingCharacter is a random capital letter
22 23
     public StreamFilter() {
23
-        this(Stream.empty(), null);
24
+        this(PersonFactory.createPersonStream(100), RandomUtils.createCharacter('A','Z'));
24 25
     }
25 26
 
26 27
     /**
@@ -28,7 +29,7 @@ public class StreamFilter {
28 29
      * @param startingCharacter - character to filter by
29 30
      */ //TODO
30 31
     public StreamFilter(Person[] people, Character startingCharacter) {
31
-        this(Stream.empty(), null);
32
+        this(Arrays.stream(people),startingCharacter);
32 33
     }
33 34
 
34 35
     /**
@@ -36,7 +37,7 @@ public class StreamFilter {
36 37
      * @param startingCharacter - character to filter by
37 38
      */ //TODO
38 39
     public StreamFilter(List<Person> people, Character startingCharacter) {
39
-        this(Stream.empty(), null);
40
+        this(people.stream(),startingCharacter );
40 41
     }
41 42
 
42 43
 
@@ -55,7 +56,7 @@ public class StreamFilter {
55 56
      * @return a list of person object whose name starts with `this.startingCharacter`
56 57
      */ //TODO
57 58
     public List<Person> toListMultiLine() {
58
-        return null;
59
+        return personStream.filter(x -> StringUtils.isPalindromeIgnoreCase(String.valueOf(x.getName().startsWith(this.startingCharacter)))).collect(Collectors.toList());
59 60
     }
60 61
 
61 62
 
@@ -64,7 +65,7 @@ public class StreamFilter {
64 65
      * @return a list of person objects whose name starts with `this.startingCharacter`
65 66
      */ //TODO
66 67
     public List<Person> toListOneLine() {
67
-        return null;
68
+        return personStream.filter(x -> StringUtils.isPalindromeIgnoreCase(String.valueOf(x.getName().startsWith(this.startingCharacter)))).collect(Collectors.toList());
68 69
     }
69 70
 
70 71
 
@@ -73,7 +74,7 @@ public class StreamFilter {
73 74
      * @return an array of person object whose name starts with `this.startingCharacter`
74 75
      */ //TODO
75 76
     public Person[] toArrayOneLine() {
76
-        return null;
77
+        return personStream.filter(person -> StringUtils.isPalindromeIgnoreCase(String.valueOf(person.getName().startsWith(this.startingCharacter)))).toArray(Person[]::new);
77 78
     }
78 79
 
79 80
 
@@ -82,7 +83,7 @@ public class StreamFilter {
82 83
      * @return an array of person object whose name starts with `this.startingCharacter`
83 84
      */ //TODO
84 85
     public Person[] toArrayMultiLine() {
85
-        return null;
86
+        return personStream.filter(person -> StringUtils.isPalindromeIgnoreCase(String.valueOf(person.getName().startsWith(this.startingCharacter)))).toArray(Person[]::new);
86 87
     }
87 88
 
88 89
 }

+ 3
- 3
src/main/java/com/zipcodewilmington/streams/StreamMap.java Parādīt failu

@@ -18,7 +18,7 @@ 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
+        return someWord.codePoints().mapToObj(x -> String.valueOf((char) x));
22 22
     }
23 23
 
24 24
     /**
@@ -26,7 +26,7 @@ public class StreamMap {
26 26
      * @return - a Stream of several Streams of single characters
27 27
      */ //TODO
28 28
     public static Stream<Stream<String>> wordsMap(String... someWords) {
29
-        return null;
29
+        return Stream.of(someWords).map(StreamMap::letters);
30 30
     }
31 31
 
32 32
     /**
@@ -34,6 +34,6 @@ public class StreamMap {
34 34
      * @return - a Stream of several Streams of single characters
35 35
      */ //TODO
36 36
     public static Stream<String> wordsFlatMap(String... stringArray) {
37
-        return null;
37
+        return Stream.of(stringArray);
38 38
     }
39 39
 }

+ 4
- 3
src/main/java/com/zipcodewilmington/streams/anthropoid/PersonFactory.java Parādīt failu

@@ -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,7 @@ 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
+        return Stream.generate(PersonFactory :: createRandomPerson).limit(listSize).collect(Collectors.toList());
43 44
     }
44 45
 
45 46
 
@@ -48,7 +49,7 @@ public final class PersonFactory {
48 49
      * @return - Array of Person objects
49 50
      */ // TODO
50 51
     public static Person[] createPersonArray(int arrayLength) {
51
-        return null;
52
+        return  Stream.generate(PersonFactory::createRandomPerson).limit(arrayLength).toArray(Person[]::new);
52 53
     }
53 54
 
54 55
 
@@ -58,6 +59,6 @@ public final class PersonFactory {
58 59
      * @return - Stream representation of collection of Person objects
59 60
      */ // TODO
60 61
     public static Stream<Person> createPersonStream(int streamCount) {
61
-        return null;
62
+        return  Stream.generate(PersonFactory::createRandomPerson).limit(streamCount);
62 63
     }
63 64
 }

+ 4
- 4
src/main/java/com/zipcodewilmington/streams/anthropoid/PersonWarehouse.java Parādīt failu

@@ -35,7 +35,7 @@ public final class PersonWarehouse {
35 35
      * @return list of uniquely named Person objects
36 36
      */ //TODO
37 37
     public static Stream<Person> getUniquelyNamedPeople() {
38
-        return null;
38
+        return people.stream().distinct();
39 39
     }
40 40
 
41 41
 
@@ -44,7 +44,7 @@ public final class PersonWarehouse {
44 44
      * @return a Stream of respective
45 45
      */ //TODO
46 46
     public static Stream<Person> getUniquelyNamedPeopleStartingWith(Character character) {
47
-        return null;
47
+        return people.stream().filter(x ->x.getName().startsWith(character.toString()));
48 48
     }
49 49
 
50 50
     /**
@@ -52,7 +52,7 @@ public final class PersonWarehouse {
52 52
      * @return a Stream of respective
53 53
      */ //TODO
54 54
     public static Stream<Person> getFirstNUniquelyNamedPeople(int n) {
55
-        return null;
55
+        return people.stream().distinct().limit(n);
56 56
     }
57 57
 
58 58
     /**
@@ -82,7 +82,7 @@ public final class PersonWarehouse {
82 82
      * @return list of names of Person objects
83 83
      */ // TODO
84 84
     public static List<String> getNames() {
85
-        return null;
85
+        return people.stream().map(x ->x.getName()).collect(Collectors.toList());
86 86
     }
87 87
 
88 88
     /**

+ 3
- 2
src/main/java/com/zipcodewilmington/streams/conversions/ArrayConverter.java Parādīt failu

@@ -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(toArray()).collect(Collectors.toList());
27 28
     }
28 29
 
29 30
     //TODO
30 31
     public Stream<Person> toStream() {
31
-        return null;
32
+        return Arrays.stream(toArray());
32 33
     }
33 34
 
34 35
     @Override

+ 4
- 2
src/main/java/com/zipcodewilmington/streams/conversions/ListConverter.java Parādīt failu

@@ -3,6 +3,8 @@ 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.Collection;
7
+import java.util.Collections;
6 8
 import java.util.List;
7 9
 import java.util.stream.Stream;
8 10
 
@@ -27,11 +29,11 @@ public final class ListConverter extends PersonConversionAgent<List<Person>> {
27 29
 
28 30
     //TODO
29 31
     public Stream<Person> toStream() {
30
-        return null;
32
+        return toList().stream();
31 33
     }
32 34
 
33 35
     //TODO
34 36
     public Person[] toArray() {
35
-        return null;
37
+        return  toList().stream().toArray(Person[]::new);
36 38
     }
37 39
 }

+ 3
- 3
src/main/java/com/zipcodewilmington/streams/conversions/StreamConverter.java Parādīt failu

@@ -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.stream().collect(Collectors.toList());
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
 }

+ 2
- 1
src/test/java/com/zipcodewilmington/streams/anthropoid/TestPersonWarehouse.java Parādīt failu

@@ -74,12 +74,13 @@ public class TestPersonWarehouse {
74 74
         }
75 75
 
76 76
         Iterator<Map.Entry<Long, String>> it = localNameMap.entrySet().iterator();
77
+        System.out.println(it.hasNext());
77 78
         while (it.hasNext()) {
78 79
             Map.Entry<Long, String> pair = it.next();
79 80
             long pairKey = pair.getKey();
80 81
             String pairValue = pair.getValue();
81 82
             String mapValue = warehouseNameMap.get(pairKey);
82
-
83
+            System.out.println(pairValue);
83 84
             Assert.assertTrue(mapValue.equals(pairValue));
84 85
         }
85 86
     }

+ 83922
- 6
target/PersonWarehouse.leonlog
Failā izmaiņas netiks attēlotas, jo tās ir par lielu
Parādīt failu


Binārs
target/classes/com/zipcodewilmington/streams/StreamFilter.class Parādīt failu


Binārs
target/classes/com/zipcodewilmington/streams/StreamMap.class Parādīt failu


Binārs
target/classes/com/zipcodewilmington/streams/anthropoid/PersonFactory.class Parādīt failu


Binārs
target/classes/com/zipcodewilmington/streams/anthropoid/PersonWarehouse.class Parādīt failu


Binārs
target/classes/com/zipcodewilmington/streams/conversions/ArrayConverter.class Parādīt failu


Binārs
target/classes/com/zipcodewilmington/streams/conversions/ListConverter.class Parādīt failu


Binārs
target/classes/com/zipcodewilmington/streams/conversions/StreamConverter.class Parādīt failu


+ 1
- 1
target/global.leonlog Parādīt failu

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

Binārs
target/test-classes/com/zipcodewilmington/streams/TestStreamMap.class Parādīt failu