Commits

RapidPM committed 684fb9e

small cleanings

Comments (0)

Files changed (6)

src/main/java/org/rapidpm/demo/entwicklerpress/shortcut/java8_streams/chap_1_2/CHAP_1_2_3.java

 
     public static void main(String[] args) {
         final List<Pair> generateDemoValues = new PairListGenerator(){}.generateDemoValues();
-
-
         //map from Point to DemoElements
         final Stream<DemoElement> demoElementStream = generateDemoValues.stream().map(v -> {
             final String value = v.getValue();
             d.setValue(Base64.getEncoder().encodeToString(value.getBytes()));
             return d;
         });
-
-
         final Stream<Pair> filteredPairStream = generateDemoValues.stream().filter(v -> v.getId() % 2 == 0);
 
-
-
-
-
-
     }
 
 }

src/main/java/org/rapidpm/demo/entwicklerpress/shortcut/java8_streams/chap_1_2/CHAP_1_2_9.java

 
 import java.util.Arrays;
 import java.util.List;
+import java.util.function.Function;
+import java.util.stream.DoubleStream;
+import java.util.stream.Stream;
 
 /**
  * Created by Sven Ruppert on 22.11.13.
  */
 public class CHAP_1_2_9 {
 
-    public static void main(String[] args) {
-        final List<Integer> demoValues
-                = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
+    public static final List<Integer> demoValues
+            = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
 
+    private static Stream<Integer> getStream() {
+        return demoValues.stream();
+    }
 
+    static final Function<Integer, Integer> f = (e) -> {
+        System.out.println("e = " + e);
+        return e;
+    };
 
+    public static void main(String[] args) {
         // true, some are matching
-        System.out.println("anyMatch " + demoValues.stream().map((e) -> {
-            System.out.println("e = " + e);
-            return e;
-        })
-                .anyMatch((v) -> v % 2 == 0));
+        System.out.println("anyMatch " + getStream().map(f).anyMatch((v) -> v % 2 == 0));
 
         //false, not all are matching
-        System.out.println("allMatch " + demoValues.stream().map((e) -> {
-            System.out.println("e = " + e);
-            return e;
-        })
+        System.out.println("allMatch " + getStream().map(f)
                 .allMatch((v) -> v % 2 == 0));
+
         //false, not all are NOT matching
-        System.out.println("noneMatch " + demoValues.stream() .map((e) -> {
-            System.out.println("e = " + e);
-            return e;
-        })
+        System.out.println("noneMatch " + getStream().map(f)
                 .noneMatch((v) -> v % 2 == 0));
 
         //5 matching the filter, 2,4,6,8,10
-        System.out.println("count " + demoValues.stream().map((e) -> {
-            System.out.println("e = " + e);
-            return e;
-        })
-                .filter((v) -> v % 2 == 0)
-                .count());
-
-
-
+        System.out.println("count " + getStream().map(f)
+                .filter((v) -> v % 2 == 0).count());
     }
 }

src/main/java/org/rapidpm/demo/entwicklerpress/shortcut/java8_streams/chap_1_3/WorkerParallelExecutorService.java

         this.executorService = executorService;
     }
 
-
     @Override
     public List<List<Integer>> generateDemoValueMatrix() {
         final List<Task> taskList = new ArrayList<>();

src/main/java/org/rapidpm/demo/entwicklerpress/shortcut/java8_streams/chap_1_5/CHAP_1_5_1.java

         }
         return true;
     }
-
 }

src/main/java/org/rapidpm/demo/entwicklerpress/shortcut/java8_streams/chap_1_5/CHAP_1_5_2.java

      */
 
     public static void main(String[] args) {
-
-
-
         final Stream<Long> fibStream = makeFibStream(10);
         fibStream.forEachOrdered(System.out::println);
-
     }
 
 

src/main/java/org/rapidpm/demo/entwicklerpress/shortcut/java8_streams/chap_1_5/CHAP_1_5_3.java

  */
 public class CHAP_1_5_3 {
     public static void main(String[] args) {
-
         final List<List<Integer>> matrix = new ArrayList<>();
-
         matrix.add(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9));
         matrix.add(Arrays.asList(1,2,3,4,5,66,7,8,9)); //hier eine 66
         matrix.add(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9));