1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kcb.quartz;
17
18 import java.util.ArrayList;
19 import java.util.Collection;
20 import java.util.List;
21
22
23
24
25
26 public class ProcessingResult<T> {
27
28
29
30 public static class Failure<T> {
31 private T item;
32 private Throwable exception;
33 private String message;
34
35 public Failure(T item) {
36 this.item = item;
37 }
38
39 public Failure(String message) {
40 this(null, null, message);
41 }
42
43 public Failure(Throwable exception) {
44 this(null, exception, null);
45 }
46
47 public Failure(Throwable exception, String message) {
48 this(null, exception, message);
49 }
50
51
52 public Failure(T item, Throwable exception) {
53 this(item, exception, null);
54 }
55
56 public Failure(T item, String message) {
57 this(item, null, message);
58 }
59
60 public Failure(T item, Throwable exception, String message) {
61 this.item = item;
62 this.exception = exception;
63 this.message = message;
64 }
65
66 public T getItem() {
67 return this.item;
68 }
69 public Throwable getException() {
70 return this.exception;
71 }
72 public String getMessage() {
73 return this.message;
74 }
75 }
76
77
78
79
80 private List<Failure<T>> failures = new ArrayList<Failure<T>>();
81
82
83
84 private List<T> successes = new ArrayList<T>();
85
86
87
88
89
90 public List<Failure<T>> getFailures() {
91 return failures;
92 }
93
94
95
96
97
98 public List<T> getSuccesses() {
99 return successes;
100 }
101
102
103
104
105
106 public void addFailure(Failure<T> o) {
107 failures.add(o);
108 }
109
110
111
112
113
114 public void addAllFailures(Collection<Failure<T>> c) {
115 failures.addAll(c);
116 }
117
118
119
120
121
122 public void addSuccess(T o) {
123 successes.add(o);
124 }
125
126
127
128
129
130 public void addAllSuccesses(Collection<T> c) {
131 successes.addAll(c);
132 }
133
134
135
136
137
138 public void add(ProcessingResult<T> result) {
139 failures.addAll(result.getFailures());
140 successes.addAll(result.getSuccesses());
141 }
142
143
144
145
146
147 public String toString() {
148 return "[ProcessingResults: successes(" + successes.size() + ")=" + successes +
149 ", failures(" + failures.size() + ")=" + failures + "]";
150 }
151 }