Leon 7 år sedan
förälder
incheckning
3e2a070605
42 ändrade filer med 962912 tillägg och 383 borttagningar
  1. 341
    321
      .idea/workspace.xml
  2. 7
    6
      src/main/java/com/zipcodewilmington/streams/StreamFilter.java
  3. 14
    3
      src/main/java/com/zipcodewilmington/streams/StreamMap.java
  4. 39
    33
      src/main/java/com/zipcodewilmington/streams/anthropoid/Person.java
  5. 3
    2
      src/main/java/com/zipcodewilmington/streams/anthropoid/PersonFactory.java
  6. 60
    0
      src/main/java/com/zipcodewilmington/streams/anthropoid/PersonWarehouse.java
  7. 4
    5
      src/main/java/com/zipcodewilmington/streams/conversions/ConversionAgent.java
  8. 1
    1
      src/main/java/com/zipcodewilmington/streams/conversions/StreamConverter.java
  9. 46
    0
      src/main/java/com/zipcodewilmington/streams/tools/DateUtils.java
  10. 1
    1
      src/main/java/com/zipcodewilmington/streams/tools/ReflectionUtils.java
  11. 5
    1
      src/main/java/com/zipcodewilmington/streams/tools/StringUtils.java
  12. 102
    0
      src/main/java/com/zipcodewilmington/streams/tools/logging/LoggerHandler.java
  13. 24
    0
      src/main/java/com/zipcodewilmington/streams/tools/logging/LoggerWarehouse.java
  14. 5
    1
      src/test/java/com/zipcodewilmington/streams/TestStreamFilter.java
  15. 2
    1
      src/test/java/com/zipcodewilmington/streams/anthropoid/TestPerson.java
  16. 2
    2
      src/test/java/com/zipcodewilmington/streams/anthropoid/TestPersonFactory.java
  17. 6
    6
      src/test/java/com/zipcodewilmington/streams/conversions/TestConversionAgent.java
  18. 531468
    0
      target/PersonWarehouse.leonlog
  19. Binär
      target/classes/com/zipcodewilmington/streams/StreamFilter.class
  20. Binär
      target/classes/com/zipcodewilmington/streams/StreamMap.class
  21. Binär
      target/classes/com/zipcodewilmington/streams/anthropoid/Person$PersonProperty.class
  22. Binär
      target/classes/com/zipcodewilmington/streams/anthropoid/Person.class
  23. Binär
      target/classes/com/zipcodewilmington/streams/anthropoid/PersonFactory.class
  24. Binär
      target/classes/com/zipcodewilmington/streams/anthropoid/PersonWarehouse.class
  25. Binär
      target/classes/com/zipcodewilmington/streams/conversions/ConversionAgent.class
  26. Binär
      target/classes/com/zipcodewilmington/streams/conversions/StreamConverter.class
  27. Binär
      target/classes/com/zipcodewilmington/streams/tools/DateUtils.class
  28. Binär
      target/classes/com/zipcodewilmington/streams/tools/StringUtils.class
  29. Binär
      target/classes/com/zipcodewilmington/streams/tools/logging/LoggerHandler.class
  30. Binär
      target/classes/com/zipcodewilmington/streams/tools/logging/LoggerWarehouse.class
  31. 2
    0
      target/global.leonlog
  32. 430780
    0
      target/global.leonlog.1
  33. Binär
      target/test-classes/com/zipcodewilmington/streams/TestStreamFilter.class
  34. Binär
      target/test-classes/com/zipcodewilmington/streams/TestStreamMap.class
  35. Binär
      target/test-classes/com/zipcodewilmington/streams/TestSuiteFullRegression.class
  36. Binär
      target/test-classes/com/zipcodewilmington/streams/anthropoid/TestPerson.class
  37. Binär
      target/test-classes/com/zipcodewilmington/streams/anthropoid/TestPersonFactory.class
  38. Binär
      target/test-classes/com/zipcodewilmington/streams/conversions/TestConversionAgent.class
  39. Binär
      target/test-classes/com/zipcodewilmington/streams/conversions/TestConverterArray.class
  40. Binär
      target/test-classes/com/zipcodewilmington/streams/conversions/TestConverterList.class
  41. Binär
      target/test-classes/com/zipcodewilmington/streams/conversions/TestConverterStream.class
  42. Binär
      target/test-classes/com/zipcodewilmington/streams/conversions/TestSuiteConversionRegression.class

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


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

@@ -3,6 +3,7 @@ package com.zipcodewilmington.streams;
3 3
 import com.zipcodewilmington.streams.anthropoid.Person;
4 4
 import com.zipcodewilmington.streams.anthropoid.PersonFactory;
5 5
 import com.zipcodewilmington.streams.tools.RandomUtils;
6
+import com.zipcodewilmington.streams.tools.StringUtils;
6 7
 
7 8
 import java.util.List;
8 9
 import java.util.stream.Collectors;
@@ -19,7 +20,7 @@ public class StreamFilter {
19 20
      * No arg constructor
20 21
      */ //TODO - construct person stream of 100 person objects; startingCharacter is a random capital letter
21 22
     public StreamFilter() {
22
-        this(PersonFactory.createPersonStream(100), RandomUtils.createCharacter('A', 'Z'));
23
+        this(PersonFactory.createPersonStream(999), RandomUtils.createCharacter('A', 'Z'));
23 24
     }
24 25
 
25 26
     /**
@@ -35,7 +36,7 @@ public class StreamFilter {
35 36
      * @param startingCharacter - character to filter by
36 37
      */ //TODO
37 38
     public StreamFilter(List<Person> people, Character startingCharacter) {
38
-        this(people.stream(), startingCharacter);
39
+        this(people.parallelStream(), startingCharacter);
39 40
     }
40 41
 
41 42
 
@@ -54,7 +55,7 @@ public class StreamFilter {
54 55
      * @return a list of person object whose name starts with `this.startingCharacter`
55 56
      */ //TODO
56 57
     public List<Person> toListMultiLine() {
57
-        Stream<Person> personStreamFiltered = personStream.filter(person -> person.name.getValue().startsWith(startingCharacter));
58
+        Stream<Person> personStreamFiltered = personStream.filter(person -> StringUtils.isPalindromeIgnoreCase(person.getName()));
58 59
         List list = personStreamFiltered.collect(Collectors.toList());
59 60
         return list;
60 61
     }
@@ -66,7 +67,7 @@ public class StreamFilter {
66 67
      */ //TODO
67 68
     public List<Person> toListOneLine() {
68 69
         return personStream
69
-                .filter(person -> person.name.getValue().startsWith(startingCharacter))
70
+                .filter(person -> StringUtils.isPalindromeIgnoreCase(person.getName()))
70 71
                 .collect(Collectors.toList());
71 72
     }
72 73
 
@@ -77,7 +78,7 @@ public class StreamFilter {
77 78
      */ //TODO
78 79
     public Person[] toArrayOneLine() {
79 80
         return personStream
80
-                .filter(person -> person.name.getValue().startsWith(startingCharacter))
81
+                .filter(person -> StringUtils.isPalindromeIgnoreCase(person.getName()))
81 82
                 .toArray(Person[]::new); // method reference
82 83
     }
83 84
 
@@ -87,7 +88,7 @@ public class StreamFilter {
87 88
      * @return an array of person object whose name starts with `this.startingCharacter`
88 89
      */ //TODO
89 90
     public Person[] toArrayMultiLine() {
90
-        Stream<Person> personStreamFiltered = personStream.filter(person -> person.name.getValue().startsWith(startingCharacter));
91
+        Stream<Person> personStreamFiltered = personStream.filter(person -> StringUtils.isPalindromeIgnoreCase(person.getName()));
91 92
         Person[] personArray = personStreamFiltered.toArray(Person[]::new); // method reference
92 93
         return personArray;
93 94
     }

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

@@ -1,5 +1,11 @@
1 1
 package com.zipcodewilmington.streams;
2 2
 
3
+import com.zipcodewilmington.streams.anthropoid.Person;
4
+import com.zipcodewilmington.streams.conversions.StreamConverter;
5
+
6
+import java.util.Arrays;
7
+import java.util.List;
8
+import java.util.stream.Collectors;
3 9
 import java.util.stream.Stream;
4 10
 
5 11
 /**
@@ -22,8 +28,13 @@ public class StreamMap {
22 28
         return Stream.of(someWords).map(w -> letters(w));
23 29
     }
24 30
 
25
-    //TODO
26
-    public static Stream<Stream<String>> wordsFlatMap(String... someWords) {
27
-        return null;//Arrays.asList(someWords).stream().flatMap(w -> letters(w));
31
+    /**
32
+     * @param stringArray - variable amount of String arguments
33
+     * @return - a Stream of several Streams of single characters
34
+     */ //TODO
35
+    public static Stream<String> wordsFlatMap(String... stringArray) {
36
+        Stream<String> wordStream = Stream.of(stringArray);
37
+        List<String> wordList = wordStream.collect(Collectors.toList());
38
+        return wordList.stream().flatMap(w -> letters(w));
28 39
     }
29 40
 }

+ 39
- 33
src/main/java/com/zipcodewilmington/streams/anthropoid/Person.java Visa fil

@@ -1,5 +1,9 @@
1 1
 package com.zipcodewilmington.streams.anthropoid;
2 2
 
3
+import com.zipcodewilmington.streams.tools.DateUtils;
4
+
5
+import java.time.LocalDate;
6
+import java.time.Period;
3 7
 import java.util.Date;
4 8
 
5 9
 /**
@@ -7,13 +11,12 @@ import java.util.Date;
7 11
  * @ATTENTION_TO_STUDENTS You are FORBIDDEN from modifying this class
8 12
  */
9 13
 public class Person {
10
-    public final PersonProperty<String> name;
11
-    public final PersonProperty<Integer> age;
12
-    public final PersonProperty<Boolean> isMale;
13
-    public final PersonProperty<Long> personalId;
14
-    public final PersonProperty<Date> birthDate;
15
-    public final PersonProperty<String[]> aliases;
16
-
14
+    public final String name;
15
+    public final int age;
16
+    public final boolean isMale;
17
+    public final long personalId;
18
+    public final Date birthDate;
19
+    public final String[] aliases;
17 20
     /**
18 21
      * @param name - name of person
19 22
      * @param age - age of person
@@ -21,33 +24,36 @@ public class Person {
21 24
      * @param personalId - unique id
22 25
      * @param birthDate - date of birth
23 26
      */
24
-    public Person(String name, int age, boolean isMale, long personalId, Date birthDate, String... aliases) {
25
-        this.name = new PersonProperty<>(name);
26
-        this.age = new PersonProperty<>(age);
27
-        this.isMale = new PersonProperty<>(isMale);
28
-        this.personalId = new PersonProperty<>(personalId);
29
-        this.birthDate = new PersonProperty<>(birthDate);
30
-        this.aliases = new PersonProperty<>(aliases);
27
+    Person(String name, int age, boolean isMale, long personalId, Date birthDate, String... aliases) {
28
+        this.name = name;
29
+        this.isMale = isMale;
30
+        this.personalId = personalId;
31
+        this.birthDate = birthDate;
32
+        this.age = DateUtils.yearsBetween(birthDate, LocalDate.now());
33
+        this.aliases = aliases;
34
+    }
35
+
36
+    public String getName() {
37
+        return name;
38
+    }
39
+
40
+    public int getAge() {
41
+        return age;
42
+    }
43
+
44
+    public boolean isMale() {
45
+        return isMale;
46
+    }
47
+
48
+    public long getPersonalId() {
49
+        return personalId;
50
+    }
51
+
52
+    public Date getBirthDate() {
53
+        return birthDate;
31 54
     }
32 55
 
33
-    /** the purpose of this class is to compress verbose getter and setter logic
34
-     * @param <E> the type of data to store */
35
-    public class PersonProperty<E> {
36
-        private E val; // value of the data
37
-
38
-        /** @param val - value of data for this object to store */
39
-        public PersonProperty(E val) {
40
-            this.val = val;
41
-        }
42
-
43
-        /** @return value this object is storing */
44
-        public E getValue() {
45
-            return val;
46
-        }
47
-
48
-        /** set value this object is storing */
49
-        public void setValue(E val) {
50
-            this.val = val;
51
-        }
56
+    public String[] getAliases() {
57
+        return aliases;
52 58
     }
53 59
 }

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

@@ -21,8 +21,8 @@ public final class PersonFactory {
21 21
      * @return a new instance of a person with fields of random values
22 22
      */
23 23
     public static Person createRandomPerson() {
24
-        String name = StringUtils.capitalizeFirstChar(RandomUtils.createString('a', 'z', 10));
25
-        String[] aliases = RandomUtils.createStrings('a', 'z', 10, 100);
24
+        String name = StringUtils.capitalizeFirstChar(RandomUtils.createString('a', 'z', 3));
25
+        String[] aliases = RandomUtils.createStrings('a', 'z', 5, 5);
26 26
         int age = RandomUtils.createInteger(0, 99);
27 27
         boolean isMale = RandomUtils.createBoolean(50);
28 28
         long personalId = System.nanoTime();
@@ -30,6 +30,7 @@ public final class PersonFactory {
30 30
 
31 31
 
32 32
         Person randomPerson = new Person(name, age, isMale, personalId, birthDate, aliases);
33
+        PersonWarehouse.addPerson(randomPerson);
33 34
         return randomPerson;
34 35
     }
35 36
 

+ 60
- 0
src/main/java/com/zipcodewilmington/streams/anthropoid/PersonWarehouse.java Visa fil

@@ -0,0 +1,60 @@
1
+package com.zipcodewilmington.streams.anthropoid;
2
+
3
+import com.zipcodewilmington.streams.tools.ReflectionUtils;
4
+import com.zipcodewilmington.streams.tools.logging.LoggerHandler;
5
+import com.zipcodewilmington.streams.tools.logging.LoggerWarehouse;
6
+
7
+import java.util.ArrayList;
8
+import java.util.Map;
9
+import java.util.stream.Collectors;
10
+import java.util.stream.Stream;
11
+
12
+/**
13
+ * Created by leon on 5/29/17.
14
+ * The warehouse is responsible for storing, retrieving, and filtering people
15
+ */
16
+public class PersonWarehouse {
17
+    private static final LoggerHandler loggerHandler = LoggerWarehouse.getLogger(PersonWarehouse.class);
18
+    private static ArrayList<Person> people = new ArrayList<>();
19
+
20
+    public static void addPerson(Person person) {
21
+        loggerHandler.disbalePrinting();
22
+        loggerHandler.info("Registering a new person object to the person warehouse...");
23
+        loggerHandler.info(ReflectionUtils.getFieldMap(person).toString());
24
+        people.add(person);
25
+    }
26
+
27
+    /**
28
+     * @return list of uniquely named Person objects
29
+     */ //TODO
30
+    public static Stream<Person> getUniquelyNamedPeople() {
31
+        ArrayList<String> names = new ArrayList<>();
32
+        return people.parallelStream().filter(
33
+                person -> !names.contains(person.getName()));
34
+    }
35
+
36
+    /**
37
+     * @param character starting character of Person objects' name
38
+     * @return a Stream of respective
39
+     */ //TODO
40
+    public static Stream<Person> getUniquelyNamedPeopleStartingWith(Character character) {
41
+        return getUniquelyNamedPeople().filter(
42
+                person -> person.getName().startsWith(character.toString()));
43
+    }
44
+
45
+    /**
46
+     * @param n starting character of Person objects' name
47
+     * @return a Stream of respective
48
+     */ //TODO
49
+    public static Stream<Person> getFirstNUniquelyNamedPeople(int n) {
50
+        return getUniquelyNamedPeople().limit(n);
51
+    }
52
+
53
+    /**
54
+     * @return a mapping of Person Id to the respective Person name
55
+     */ // TODO
56
+    public static Map<Long, String> getIdToNameMap() {
57
+        return people.parallelStream().collect(
58
+                Collectors.toMap(p -> p.getPersonalId(), p -> p.getName()));
59
+    }
60
+}

+ 4
- 5
src/main/java/com/zipcodewilmington/streams/conversions/ConversionAgent.java Visa fil

@@ -6,17 +6,16 @@ import java.util.List;
6 6
 import java.util.function.Function;
7 7
 import java.util.function.Predicate;
8 8
 import java.util.stream.Stream;
9
-
10 9
 /**
11 10
  * Created by leon on 5/25/17.
12
- * ConversionAgent is responsible for conversion between different collection types
13
- * for the sake of this assignment and my sanity, consider primitive arrays to be collection type
11
+ * ConversionAgent is responsible for conversion between different object sequent data types
12
+ * Object sequent data types include: collections, arrays, lists, maps, iterators
14 13
  */
15 14
 public abstract class ConversionAgent<T> {
16 15
     protected T people;
17 16
 
18
-    public ConversionAgent(T val) {
19
-        this.people = val;
17
+    public ConversionAgent(T objectSequence) {
18
+        this.people = objectSequence;
20 19
     }
21 20
 
22 21
     abstract public List<Person> toList();

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

@@ -30,7 +30,7 @@ public final class StreamConverter extends ConversionAgent<Stream<Person>> {
30 30
 
31 31
     // TODO
32 32
     public Stream<Person> toStream() {
33
-        return this.personList.stream();
33
+        return this.personList.parallelStream();
34 34
     }
35 35
 
36 36
     // TODO

+ 46
- 0
src/main/java/com/zipcodewilmington/streams/tools/DateUtils.java Visa fil

@@ -0,0 +1,46 @@
1
+package com.zipcodewilmington.streams.tools;
2
+
3
+import java.time.*;
4
+import java.util.Date;
5
+
6
+/**
7
+ * Created by leon on 5/1/17.
8
+ * @ATTENTION_TO_STUDENTS You are FORBIDDEN from modifying this class
9
+ */
10
+public final class DateUtils {
11
+    private DateUtils() {
12
+        /** this class is uninstantiable */
13
+    }
14
+
15
+    /**
16
+     * @param localDate LocalDate object to convert
17
+     * @return respective Date-object-representation
18
+     */
19
+    public static Date asDate(LocalDate localDate) {
20
+        return Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
21
+    }
22
+
23
+    public static Date asDate(LocalDateTime localDateTime) {
24
+        return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
25
+    }
26
+
27
+    public static LocalDate asLocalDate(Date date) {
28
+        return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDate();
29
+    }
30
+
31
+    public static LocalDateTime asLocalDateTime(Date date) {
32
+        return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDateTime();
33
+    }
34
+
35
+    public static int yearsBetween(Date startDate, Date endDate) {
36
+        return yearsBetween(DateUtils.asLocalDate(startDate), DateUtils.asLocalDate(endDate));
37
+    }
38
+
39
+    public static int yearsBetween(Date startDate, LocalDate endDate) {
40
+        return yearsBetween(DateUtils.asLocalDate(startDate), endDate);
41
+    }
42
+
43
+    public static int yearsBetween(LocalDate startDate, LocalDate endDate) {
44
+        return Period.between(startDate, endDate).getYears();
45
+    }
46
+}

+ 1
- 1
src/main/java/com/zipcodewilmington/streams/tools/ReflectionUtils.java Visa fil

@@ -32,7 +32,7 @@ public class ReflectionUtils {
32 32
             try {
33 33
                 boolean defaultAccess = f.isAccessible();
34 34
 
35
-                // attempt to modify visibility
35
+                // attempt to modify field visibility
36 36
                 f.setAccessible(true);
37 37
                 hm.put(f, f.get(object).toString());
38 38
                 f.setAccessible(defaultAccess);

+ 5
- 1
src/main/java/com/zipcodewilmington/streams/tools/StringUtils.java Visa fil

@@ -43,6 +43,10 @@ public class StringUtils {
43 43
      * @return the padded-left String
44 44
      */
45 45
     public static String padRight(String s, int n) {
46
-        return String.format("%1$-" + n + "s", s);
46
+        return padLeft(s, -n);
47
+    }
48
+
49
+    public static boolean isPalindromeIgnoreCase(String str) {
50
+        return new StringBuilder(str).reverse().toString().equalsIgnoreCase(str);
47 51
     }
48 52
 }

+ 102
- 0
src/main/java/com/zipcodewilmington/streams/tools/logging/LoggerHandler.java Visa fil

@@ -0,0 +1,102 @@
1
+package com.zipcodewilmington.streams.tools.logging;
2
+
3
+
4
+import java.io.IOException;
5
+import java.io.PrintWriter;
6
+import java.io.StringWriter;
7
+import java.util.logging.*;
8
+import java.util.stream.Stream;
9
+
10
+import static java.util.logging.Level.*;
11
+
12
+/**
13
+ * Created by leon on 5/15/17.
14
+ */
15
+public final class LoggerHandler {
16
+    private final Logger logger;
17
+    private final String loggerName;
18
+    private boolean printingEnabled;
19
+
20
+    public LoggerHandler(Class c) {
21
+        this(c.getSimpleName());
22
+    }
23
+
24
+    public LoggerHandler(String loggerName) {
25
+        this(Logger.getLogger(loggerName));
26
+    }
27
+
28
+    public LoggerHandler(Logger logger) {
29
+        this.logger = logger;
30
+        this.loggerName = logger.getName();
31
+        this.logger.addHandler(getFileHandler());
32
+        this.printingEnabled = true;
33
+    }
34
+
35
+    public void throwable(Throwable t, Level level) {
36
+        StringWriter out = new StringWriter();
37
+        t.printStackTrace(new PrintWriter(out));
38
+        String description = out.toString();
39
+        log(level, description);
40
+    }
41
+
42
+    public void throwable(Throwable t) {
43
+        throwable(t, WARNING);
44
+    }
45
+
46
+    public void info(String s, Object... args) {
47
+        log(INFO, s, args);
48
+    }
49
+
50
+    public void warn(String s, Object... args) {
51
+        log(WARNING, String.format(s, args));
52
+    }
53
+
54
+    public void error(String s, Object... args) {
55
+        log(SEVERE, s, args);
56
+    }
57
+
58
+    private void log(Level level, String message, Object... messageArgs) {
59
+        if(printingEnabled) {
60
+            System.out.println(String.format(message, messageArgs));
61
+        }
62
+        logger.log(level, String.format(message, messageArgs));
63
+    }
64
+
65
+    public void setLevel(Level level) {
66
+        logger.setLevel(level);
67
+    }
68
+
69
+    public void enablePrinting() {
70
+        this.printingEnabled = true;
71
+    }
72
+
73
+    public void disbalePrinting() {
74
+        this.printingEnabled = false;
75
+    }
76
+
77
+    private FileHandler getFileHandler() {
78
+        return getFileHandler(new SimpleFormatter());
79
+    }
80
+
81
+    private FileHandler getFileHandler(Formatter formatter) {
82
+        FileHandler fh = null;
83
+        try {
84
+            removeHandlers(); // enables better printing control
85
+            String fileName = String.format("./target/%s.leonlog", loggerName, System.nanoTime());
86
+            fh = new FileHandler(fileName);
87
+            fh.setFormatter(formatter);
88
+        } catch (IOException ioe) {
89
+            ioe.printStackTrace();
90
+        } catch (NullPointerException npe) {
91
+
92
+        }
93
+        return fh;
94
+    }
95
+
96
+    private void removeHandlers() {
97
+        logger.setUseParentHandlers(false);
98
+        for (Handler handler : logger.getHandlers()) {
99
+            logger.removeHandler(handler);
100
+        }
101
+    }
102
+}

+ 24
- 0
src/main/java/com/zipcodewilmington/streams/tools/logging/LoggerWarehouse.java Visa fil

@@ -0,0 +1,24 @@
1
+package com.zipcodewilmington.streams.tools.logging;
2
+
3
+import java.util.HashMap;
4
+import java.util.logging.Logger;
5
+
6
+/**
7
+ * Created by leon on 5/15/17.
8
+ */
9
+public class LoggerWarehouse {
10
+    public static final LoggerHandler globalLogger = new LoggerHandler(Logger.getGlobal());
11
+    private static final HashMap<Class, LoggerHandler> loggerMap = new HashMap<>();
12
+
13
+    public static final LoggerHandler getLogger(Class c) {
14
+        addLogger(c);
15
+        return loggerMap.get(c);
16
+    }
17
+
18
+    private static final void addLogger(Class c) {
19
+        if (!loggerMap.containsKey(c)) {
20
+            globalLogger.info(String.format("Instantiating logger for [ %s ] ... ", c.getName()));
21
+            loggerMap.put(c, new LoggerHandler(c));
22
+        }
23
+    }
24
+}

+ 5
- 1
src/test/java/com/zipcodewilmington/streams/TestStreamFilter.java Visa fil

@@ -1,6 +1,9 @@
1 1
 package com.zipcodewilmington.streams;
2 2
 
3 3
 import com.zipcodewilmington.streams.anthropoid.Person;
4
+import com.zipcodewilmington.streams.tools.StringUtils;
5
+import com.zipcodewilmington.streams.tools.logging.LoggerHandler;
6
+import com.zipcodewilmington.streams.tools.logging.LoggerWarehouse;
4 7
 import org.junit.Before;
5 8
 import org.junit.Test;
6 9
 
@@ -47,8 +50,9 @@ public class TestStreamFilter {
47 50
     }
48 51
 
49 52
     private void testFilter(List<Person> persons) {
53
+        assert(persons.size() > 0);
50 54
         for (Person p : persons) {
51
-            assert (p.name.getValue().startsWith(streamFilter.startingCharacter));
55
+            assert (StringUtils.isPalindromeIgnoreCase(p.getName()));
52 56
         }
53 57
     }
54 58
 }

+ 2
- 1
src/test/java/com/zipcodewilmington/streams/anthropoid/TestPerson.java Visa fil

@@ -2,7 +2,8 @@ package com.zipcodewilmington.streams.anthropoid;
2 2
 
3 3
 /**
4 4
  * Created by leon on 5/25/17.
5
+ *
5 6
  * @ATTENTION_TO_STUDENTS You are FORBIDDEN from modifying this class
6 7
  */
7 8
 public class TestPerson {
8
-}
9
+}

+ 2
- 2
src/test/java/com/zipcodewilmington/streams/anthropoid/TestPersonFactory.java Visa fil

@@ -33,12 +33,13 @@ public class TestPersonFactory implements TestConstants {
33 33
         checkStream(PersonFactory.createPersonStream(collectionSize));
34 34
     }
35 35
 
36
+    //8.1 - 8.6; 8.7 - rest
36 37
     private final void checkStream(Stream<Person> personStream) {
37 38
         String messageCheckSize = "Ensuring appropriately sized stream was produced.";
38 39
 
39 40
         Person[] personArray = personStream.toArray(Person[]::new);
40 41
         Assert.assertEquals(messageCheckSize, collectionSize, personArray.length);
41
-        for (Person person : personArray) { // TODO - Move to a `TestPerson` class
42
+        for (Person person : personArray) {
42 43
            checkPerson(person);
43 44
         }
44 45
     }
@@ -48,7 +49,6 @@ public class TestPersonFactory implements TestConstants {
48 49
         String messageCheckValue = "Ensuring field-value is non-null";
49 50
 
50 51
         HashMap<Field, String> fieldMap = ReflectionUtils.getFieldMap(person);
51
-        System.out.println(fieldMap.toString());
52 52
         for (Map.Entry<Field, String> entry : fieldMap.entrySet()) {
53 53
             Field key = entry.getKey();
54 54
             String value = entry.getValue();

+ 6
- 6
src/test/java/com/zipcodewilmington/streams/conversions/TestConversionAgent.java Visa fil

@@ -44,8 +44,8 @@ public class TestConversionAgent<T extends ConversionAgent> {
44 44
     @Test
45 45
     public void testToList() {
46 46
         for (int i = 0; i < personList.size(); i++) {
47
-            long listId = personList.get(i).personalId.getValue();
48
-            long arrayId = personArray[i].personalId.getValue();
47
+            long listId = personList.get(i).getPersonalId();
48
+            long arrayId = personArray[i].getPersonalId();
49 49
 
50 50
             Assert.assertEquals(listId, arrayId);
51 51
         }
@@ -57,8 +57,8 @@ public class TestConversionAgent<T extends ConversionAgent> {
57 57
         List<Person> people = personStream.collect(Collectors.toList());
58 58
 
59 59
         for (int i = 0; i < people.size(); i++) {
60
-            long arrayId = personArray[i].personalId.getValue();
61
-            long streamId = people.get(i).personalId.getValue();
60
+            long arrayId = personArray[i].getPersonalId();
61
+            long streamId = people.get(i).getPersonalId();
62 62
 
63 63
             Assert.assertEquals(streamId, arrayId);
64 64
         }
@@ -67,8 +67,8 @@ public class TestConversionAgent<T extends ConversionAgent> {
67 67
     @Test
68 68
     public void testToArray() {
69 69
         for (int i = 0; i < personArray.length; i++) {
70
-            long arrayId = personArray[i].personalId.getValue();
71
-            long listId = personList.get(i).personalId.getValue();
70
+            long arrayId = personArray[i].getPersonalId();
71
+            long listId = personList.get(i).getPersonalId();
72 72
 
73 73
             Assert.assertEquals(listId, arrayId);
74 74
         }

+ 531468
- 0
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/StreamMap.class Visa fil


Binär
target/classes/com/zipcodewilmington/streams/anthropoid/Person$PersonProperty.class Visa fil


Binär
target/classes/com/zipcodewilmington/streams/anthropoid/Person.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


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


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


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


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


Binär
target/classes/com/zipcodewilmington/streams/tools/logging/LoggerHandler.class Visa fil


Binär
target/classes/com/zipcodewilmington/streams/tools/logging/LoggerWarehouse.class Visa fil


+ 2
- 0
target/global.leonlog Visa fil

@@ -0,0 +1,2 @@
1
+May 30, 2017 4:24:18 PM com.zipcodewilmington.streams.tools.logging.LoggerHandler log
2
+INFO: Instantiating logger for [ com.zipcodewilmington.streams.anthropoid.PersonWarehouse ] ... 

+ 430780
- 0
target/global.leonlog.1
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


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


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


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


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


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


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


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


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


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


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