Kaynağa Gözat

Passed Most tests

Akeem Cherry 6 yıl önce
ebeveyn
işleme
021ba77a63
23 değiştirilmiş dosya ile 850946 ekleme ve 963 silme
  1. 2
    0
      .idea/compiler.xml
  2. 0
    13
      .idea/libraries/Maven__junit_junit_4_12.xml
  3. 13
    0
      .idea/libraries/Maven__junit_junit_4_13_beta_1.xml
  4. 491
    917
      .idea/workspace.xml
  5. 12
    0
      pom.xml
  6. 7
    7
      src/main/java/com/zipcodewilmington/streams/StreamFilter.java
  7. 3
    3
      src/main/java/com/zipcodewilmington/streams/StreamMap.java
  8. 6
    3
      src/main/java/com/zipcodewilmington/streams/anthropoid/PersonFactory.java
  9. 7
    5
      src/main/java/com/zipcodewilmington/streams/anthropoid/PersonWarehouse.java
  10. 3
    2
      src/main/java/com/zipcodewilmington/streams/conversions/ArrayConverter.java
  11. 3
    2
      src/main/java/com/zipcodewilmington/streams/conversions/ListConverter.java
  12. 3
    3
      src/main/java/com/zipcodewilmington/streams/conversions/StreamConverter.java
  13. 1
    1
      streamdemo.iml
  14. 850394
    6
      target/PersonWarehouse.leonlog
  15. BIN
      target/classes/com/zipcodewilmington/streams/StreamFilter.class
  16. BIN
      target/classes/com/zipcodewilmington/streams/StreamMap.class
  17. BIN
      target/classes/com/zipcodewilmington/streams/anthropoid/PersonFactory.class
  18. BIN
      target/classes/com/zipcodewilmington/streams/anthropoid/PersonWarehouse.class
  19. BIN
      target/classes/com/zipcodewilmington/streams/conversions/ArrayConverter.class
  20. BIN
      target/classes/com/zipcodewilmington/streams/conversions/ListConverter.class
  21. BIN
      target/classes/com/zipcodewilmington/streams/conversions/StreamConverter.class
  22. 1
    1
      target/global.leonlog
  23. BIN
      target/test-classes/com/zipcodewilmington/streams/TestStreamMap.class

+ 2
- 0
.idea/compiler.xml Dosyayı Görüntüle

@@ -7,10 +7,12 @@
7 7
         <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
8 8
         <outputRelativeToContentRoot value="true" />
9 9
         <module name="looptest" />
10
+        <module name="streamdemo" />
10 11
       </profile>
11 12
     </annotationProcessing>
12 13
     <bytecodeTargetLevel target="1.8">
13 14
       <module name="looptest" target="1.8" />
15
+      <module name="streamdemo" target="1.8" />
14 16
     </bytecodeTargetLevel>
15 17
   </component>
16 18
 </project>

+ 0
- 13
.idea/libraries/Maven__junit_junit_4_12.xml Dosyayı Görüntüle

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

+ 13
- 0
.idea/libraries/Maven__junit_junit_4_13_beta_1.xml Dosyayı Görüntüle

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

+ 491
- 917
.idea/workspace.xml
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 12
- 0
pom.xml Dosyayı Görüntüle

@@ -15,5 +15,17 @@
15 15
         </dependency>
16 16
     </dependencies>
17 17
 
18
+    <build>
19
+        <plugins>
20
+            <plugin>
21
+                <groupId>org.apache.maven.plugins</groupId>
22
+                <artifactId>maven-compiler-plugin</artifactId>
23
+                <configuration>
24
+                    <source>1.8</source>
25
+                    <target>1.8</target>
26
+                </configuration>
27
+            </plugin>
28
+        </plugins>
29
+    </build>
18 30
 
19 31
 </project>

+ 7
- 7
src/main/java/com/zipcodewilmington/streams/StreamFilter.java Dosyayı Görüntüle

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

+ 3
- 3
src/main/java/com/zipcodewilmington/streams/StreamMap.java Dosyayı Görüntüle

@@ -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 Stream.of(someWord);
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(x -> letters(x));
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).flatMap(x -> letters(x));
38 38
     }
39 39
 }

+ 6
- 3
src/main/java/com/zipcodewilmington/streams/anthropoid/PersonFactory.java Dosyayı Görüntüle

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

+ 7
- 5
src/main/java/com/zipcodewilmington/streams/anthropoid/PersonWarehouse.java Dosyayı Görüntüle

@@ -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,14 +52,16 @@ 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
+
56
+        return people.stream().distinct().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
+
64
+        return people.stream().collect(Collectors.toMap(Person::getPersonalId, Person::getName));
63 65
     }
64 66
 
65 67
 
@@ -82,7 +84,7 @@ public final class PersonWarehouse {
82 84
      * @return list of names of Person objects
83 85
      */ // TODO
84 86
     public static List<String> getNames() {
85
-        return null;
87
+        return people.stream().map(x -> x.getName()).collect(Collectors.toList());
86 88
     }
87 89
 
88 90
     /**

+ 3
- 2
src/main/java/com/zipcodewilmington/streams/conversions/ArrayConverter.java Dosyayı Görüntüle

@@ -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 Arrays.stream(super.objectSequence);
32 33
     }
33 34
 
34 35
     @Override

+ 3
- 2
src/main/java/com/zipcodewilmington/streams/conversions/ListConverter.java Dosyayı Görüntüle

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

+ 3
- 3
src/main/java/com/zipcodewilmington/streams/conversions/StreamConverter.java Dosyayı Görüntüle

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

+ 1
- 1
streamdemo.iml Dosyayı Görüntüle

@@ -11,7 +11,7 @@
11 11
     </content>
12 12
     <orderEntry type="inheritedJdk" />
13 13
     <orderEntry type="sourceFolder" forTests="false" />
14
-    <orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
14
+    <orderEntry type="library" name="Maven: junit:junit:4.13-beta-1" level="project" />
15 15
     <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
16 16
   </component>
17 17
 </module>

+ 850394
- 6
target/PersonWarehouse.leonlog
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


BIN
target/classes/com/zipcodewilmington/streams/StreamFilter.class Dosyayı Görüntüle


BIN
target/classes/com/zipcodewilmington/streams/StreamMap.class Dosyayı Görüntüle


BIN
target/classes/com/zipcodewilmington/streams/anthropoid/PersonFactory.class Dosyayı Görüntüle


BIN
target/classes/com/zipcodewilmington/streams/anthropoid/PersonWarehouse.class Dosyayı Görüntüle


BIN
target/classes/com/zipcodewilmington/streams/conversions/ArrayConverter.class Dosyayı Görüntüle


BIN
target/classes/com/zipcodewilmington/streams/conversions/ListConverter.class Dosyayı Görüntüle


BIN
target/classes/com/zipcodewilmington/streams/conversions/StreamConverter.class Dosyayı Görüntüle


+ 1
- 1
target/global.leonlog Dosyayı Görüntüle

@@ -1,2 +1,2 @@
1
-May 31, 2017 4:45:59 PM com.zipcodewilmington.streams.tools.logging.LoggerHandler log
1
+Nov 29, 2018 8:33:43 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/TestStreamMap.class Dosyayı Görüntüle