22
22
* also compose a {@link CompletableFuture} of that list of values via {@link #toCompletableFuture()}
23
23
*/
24
24
public interface PromisedValues <T > {
25
+
25
26
/**
26
27
* Returns a new {@link PromisedValues} that is completed when all of
27
28
* the given {@link CompletableFuture}s complete. If any of the given
@@ -31,7 +32,7 @@ public interface PromisedValues<T> {
31
32
* @param cfs the {@link CompletableFuture}s to combine
32
33
* @param <T> the type of values
33
34
*
34
- * @return a new CombinedFutures
35
+ * @return a new PromisedValues
35
36
*/
36
37
static <T > PromisedValues <T > allOf (List <CompletableFuture <T >> cfs ) {
37
38
return PromisedValuesImpl .combineAllOf (cfs );
@@ -47,7 +48,7 @@ static <T> PromisedValues<T> allOf(List<CompletableFuture<T>> cfs) {
47
48
* @param f2 the 2nd completable future
48
49
* @param <T> the type of values
49
50
*
50
- * @return a new CombinedFutures
51
+ * @return a new PromisedValues
51
52
*/
52
53
static <T > PromisedValues <T > allOf (CompletableFuture <T > f1 , CompletableFuture <T > f2 ) {
53
54
return PromisedValuesImpl .combineAllOf (asList (f1 , f2 ));
@@ -64,12 +65,13 @@ static <T> PromisedValues<T> allOf(CompletableFuture<T> f1, CompletableFuture<T>
64
65
* @param f3 the 3rd completable future
65
66
* @param <T> the type of values
66
67
*
67
- * @return a new CombinedFutures
68
+ * @return a new PromisedValues
68
69
*/
69
70
static <T > PromisedValues allOf (CompletableFuture <T > f1 , CompletableFuture <T > f2 , CompletableFuture <T > f3 ) {
70
71
return PromisedValuesImpl .combineAllOf (asList (f1 , f2 , f3 ));
71
72
}
72
73
74
+
73
75
/**
74
76
* Returns a new {@link PromisedValues} that is completed when all of
75
77
* the given {@link CompletableFuture}s complete. If any of the given
@@ -82,12 +84,80 @@ static <T> PromisedValues allOf(CompletableFuture<T> f1, CompletableFuture<T> f2
82
84
* @param f4 the 4th completable future
83
85
* @param <T> the type of values
84
86
*
85
- * @return a new CombinedFutures
87
+ * @return a new PromisedValues
86
88
*/
87
89
static <T > PromisedValues allOf (CompletableFuture <T > f1 , CompletableFuture <T > f2 , CompletableFuture <T > f3 , CompletableFuture <T > f4 ) {
88
90
return PromisedValuesImpl .combineAllOf (asList (f1 , f2 , f3 , f4 ));
89
91
}
90
92
93
+
94
+ /**
95
+ * Returns a new {@link PromisedValues} that is completed when all of
96
+ * the given {@link PromisedValues}s complete. If any of the given
97
+ * {@link PromisedValues}s complete exceptionally, then the returned
98
+ * {@link PromisedValues} also does so.
99
+ *
100
+ * @param cfs the list to combine
101
+ * @param <T> the type of values
102
+ *
103
+ * @return a new PromisedValues
104
+ */
105
+ static <T > PromisedValues <T > allPromisedValues (List <PromisedValues <T >> cfs ) {
106
+ return PromisedValuesImpl .combinePromisedValues (cfs );
107
+ }
108
+
109
+ /**
110
+ * Returns a new {@link PromisedValues} that is completed when all of
111
+ * the given {@link PromisedValues}s complete. If any of the given
112
+ * {@link PromisedValues}s complete exceptionally, then the returned
113
+ * {@link PromisedValues} also does so.
114
+ *
115
+ * @param pv1 the 1st promised value
116
+ * @param pv2 the 2nd promised value
117
+ * @param <T> the type of values
118
+ *
119
+ * @return a new PromisedValues
120
+ */
121
+ static <T > PromisedValues <T > allPromisedValues (PromisedValues <T > pv1 , PromisedValues <T > pv2 ) {
122
+ return PromisedValuesImpl .combinePromisedValues (asList (pv1 , pv2 ));
123
+ }
124
+
125
+ /**
126
+ * Returns a new {@link PromisedValues} that is completed when all of
127
+ * the given {@link PromisedValues}s complete. If any of the given
128
+ * {@link PromisedValues}s complete exceptionally, then the returned
129
+ * {@link PromisedValues} also does so.
130
+ *
131
+ * @param pv1 the 1st promised value
132
+ * @param pv2 the 2nd promised value
133
+ * @param pv3 the 3rd promised value
134
+ * @param <T> the type of values
135
+ *
136
+ * @return a new PromisedValues
137
+ */
138
+ static <T > PromisedValues <T > allPromisedValues (PromisedValues <T > pv1 , PromisedValues <T > pv2 , PromisedValues <T > pv3 ) {
139
+ return PromisedValuesImpl .combinePromisedValues (asList (pv1 , pv2 , pv3 ));
140
+ }
141
+
142
+ /**
143
+ * Returns a new {@link PromisedValues} that is completed when all of
144
+ * the given {@link PromisedValues}s complete. If any of the given
145
+ * {@link PromisedValues}s complete exceptionally, then the returned
146
+ * {@link PromisedValues} also does so.
147
+ *
148
+ * @param pv1 the 1st promised value
149
+ * @param pv2 the 2nd promised value
150
+ * @param pv3 the 3rd promised value
151
+ * @param pv4 the 4th promised value
152
+ * @param <T> the type of values
153
+ *
154
+ * @return a new PromisedValues
155
+ */
156
+ static <T > PromisedValues <T > allPromisedValues (PromisedValues <T > pv1 , PromisedValues <T > pv2 , PromisedValues <T > pv3 , PromisedValues <T > pv4 ) {
157
+ return PromisedValuesImpl .combinePromisedValues (asList (pv1 , pv2 , pv3 , pv4 ));
158
+ }
159
+
160
+
91
161
/**
92
162
* When the all the futures complete, this call back will be invoked with this {@link PromisedValues} as a parameter
93
163
*
@@ -169,11 +239,14 @@ static <T> PromisedValues allOf(CompletableFuture<T> f1, CompletableFuture<T> f2
169
239
* (unchecked) {@link CompletionException} with the underlying
170
240
* exception as its cause.
171
241
*
242
+ * @return the list of completed values similar to {@link #toList()}
243
+ *
172
244
* @throws CancellationException if the computation was cancelled
173
245
* @throws CompletionException if this future completed
174
246
* exceptionally or a completion computation threw an exception
247
+ *
175
248
*/
176
- void join ();
249
+ List < T > join ();
177
250
178
251
/**
179
252
* @return this as a {@link CompletableFuture} that returns the list of underlying values
0 commit comments