1
1
package adventofcode ;
2
2
3
+ import org .apache .commons .lang3 .ArrayUtils ;
4
+ import org .jeasy .rules .api .Facts ;
5
+ import org .jeasy .rules .api .Rules ;
6
+ import org .jeasy .rules .api .RulesEngine ;
7
+ import org .jeasy .rules .api .RulesEngineParameters ;
8
+ import org .jeasy .rules .core .InferenceRulesEngine ;
9
+
3
10
import java .io .IOException ;
4
11
import java .net .URISyntaxException ;
5
12
import java .nio .file .Files ;
6
13
import java .nio .file .Path ;
7
14
import java .util .List ;
8
15
import java .util .Objects ;
9
16
10
- import org .jeasy .rules .api .Facts ;
11
- import org .jeasy .rules .api .Rules ;
12
- import org .jeasy .rules .api .RulesEngine ;
13
- import org .jeasy .rules .api .RulesEngineParameters ;
14
- import org .jeasy .rules .core .InferenceRulesEngine ;
15
-
16
17
public class Utils {
17
18
18
- private static RulesEngine ENGINE = new InferenceRulesEngine (new RulesEngineParameters (false , false , false , Integer .MAX_VALUE ));
19
+ private static final RulesEngine ENGINE = new InferenceRulesEngine (new RulesEngineParameters (false , false , false , Integer .MAX_VALUE ));
19
20
20
21
private Utils () {}
21
22
@@ -40,6 +41,18 @@ public static void exec(String[] args, Runnable part1, Runnable part2) {
40
41
}
41
42
}
42
43
44
+ public static void exec (Runnable ... parts ) {
45
+ if (ArrayUtils .isEmpty (parts )) {
46
+ System .out .println ("Nothing to do" );
47
+ return ;
48
+ }
49
+
50
+ for (int i = 0 ; i < parts .length ; i ++) {
51
+ System .out .println ("## Running part " + (i + 1 ));
52
+ parts [i ].run ();
53
+ }
54
+ }
55
+
43
56
public static void fire (Rules rules , Facts facts ) {
44
57
ENGINE .fire (rules , facts );
45
58
}
0 commit comments