1 package com.guinetik.corefun.examples;
2
3
4
5
6
7
8
9 public class AllExamples {
10
11 public static void main(String[] args) {
12 System.out.println("╔══════════════════════════════════════════════════════════════╗");
13 System.out.println("║ CoreFun - Functional Primitives ║");
14 System.out.println("║ Example Gallery ║");
15 System.out.println("╚══════════════════════════════════════════════════════════════╝");
16 System.out.println();
17
18 runExample("Result<S, F>", ResultExample::main);
19 runExample("Try", TryExample::main);
20 runExample("Computable<T>", ComputableExample::main);
21 runExample("SafeExecutor", SafeExecutorExample::main);
22
23 System.out.println("╔══════════════════════════════════════════════════════════════╗");
24 System.out.println("║ All Examples Complete ║");
25 System.out.println("╚══════════════════════════════════════════════════════════════╝");
26 }
27
28 private static void runExample(String name, java.util.function.Consumer<String[]> example) {
29 System.out.println("┌──────────────────────────────────────────────────────────────┐");
30 System.out.println("│ Running: " + padRight(name, 51) + "│");
31 System.out.println("└──────────────────────────────────────────────────────────────┘");
32 System.out.println();
33
34 try {
35 example.accept(new String[0]);
36 } catch (Exception e) {
37 System.err.println("Example failed: " + e.getMessage());
38 e.printStackTrace();
39 }
40
41 System.out.println();
42 System.out.println("════════════════════════════════════════════════════════════════");
43 System.out.println();
44 }
45
46 private static String padRight(String s, int n) {
47 return String.format("%-" + n + "s", s);
48 }
49 }