1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package com.github.dexecutor.executor;
19
20 import java.util.concurrent.ExecutorService;
21
22 import com.github.dexecutor.executor.graph.CyclicValidator;
23 import com.github.dexecutor.executor.graph.LevelOrderTraversar;
24 import com.github.dexecutor.executor.graph.Traversar;
25 import com.github.dexecutor.executor.graph.Validator;
26 import static com.github.dexecutor.executor.support.Preconditions.*;
27
28
29
30
31
32
33
34
35
36
37 public class DependentTasksExecutorConfig<T extends Comparable<T>, R> {
38
39
40
41 private ExecutorService executorService;
42
43
44
45 private TaskProvider<T, R> taskProvider;
46
47
48
49 private Validator<T, R> validator = new CyclicValidator<T, R>();
50
51
52
53 private Traversar<T, R> traversar = new LevelOrderTraversar<T, R>();
54
55
56
57
58
59 public DependentTasksExecutorConfig(final ExecutorService executorService, final TaskProvider<T, R> taskProvider) {
60 this.executorService = executorService;
61 this.taskProvider = taskProvider;
62 }
63
64 void validate() {
65 checkNotNull(this.executorService, "Executer Service should not be null");
66 checkNotNull(this.taskProvider, "Task Provider should not be null");
67 checkNotNull(this.validator, "Validator should not be null");
68 checkNotNull(this.traversar, "Traversar should not be null");
69 }
70
71 ExecutorService getExecutorService() {
72 return executorService;
73 }
74
75 TaskProvider<T, R> getTaskProvider() {
76 return taskProvider;
77 }
78
79 Validator<T, R> getValidator() {
80 return validator;
81 }
82
83
84
85
86 public void setValidator(final Validator<T, R> validator) {
87 this.validator = validator;
88 }
89 Traversar<T, R> getTraversar() {
90 return traversar;
91 }
92
93
94
95
96 public void setTraversar(final Traversar<T, R> traversar) {
97 this.traversar = traversar;
98 }
99 }