Skip to content

Commit a44ea77

Browse files
committed
Formatting
1 parent 6ecb93d commit a44ea77

File tree

5 files changed

+136
-49
lines changed

5 files changed

+136
-49
lines changed

src/main/java/net/tascalate/concurrent/ConfigurableDependentPromise.java

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ public class ConfigurableDependentPromise<T> implements DependentPromise<T> {
7979
final protected CompletionStage<?>[] cancellableOrigins;
8080
final private Set<PromiseOrigin> defaultEnlistOptions;
8181

82-
protected ConfigurableDependentPromise(Promise<T> delegate, Set<PromiseOrigin> defaultEnlistOptions, CompletionStage<?>[] cancellableOrigins) {
82+
protected ConfigurableDependentPromise(Promise<T> delegate,
83+
Set<PromiseOrigin> defaultEnlistOptions,
84+
CompletionStage<?>[] cancellableOrigins) {
8385
this.delegate = delegate;
8486
this.defaultEnlistOptions = defaultEnlistOptions == null || defaultEnlistOptions.isEmpty() ?
8587
PromiseOrigin.NONE : defaultEnlistOptions;
@@ -98,7 +100,9 @@ protected <U> DependentPromise<U> wrap(Promise<U> original, CompletionStage<?>[]
98100
return doWrap(original, defaultEnlistOptions, cancellableOrigins);
99101
}
100102

101-
private static <U> DependentPromise<U> doWrap(Promise<U> original, Set<PromiseOrigin> defaultEnlistOptions, CompletionStage<?>[] cancellableOrigins) {
103+
private static <U> DependentPromise<U> doWrap(Promise<U> original,
104+
Set<PromiseOrigin> defaultEnlistOptions,
105+
CompletionStage<?>[] cancellableOrigins) {
102106
if (null == cancellableOrigins || cancellableOrigins.length == 0) {
103107
// Nothing to enlist additionally for this "original" instance
104108
if (original instanceof ConfigurableDependentPromise) {
@@ -109,7 +113,9 @@ private static <U> DependentPromise<U> doWrap(Promise<U> original, Set<PromiseOr
109113
}
110114
}
111115
}
112-
final ConfigurableDependentPromise<U> result = new ConfigurableDependentPromise<>(original, defaultEnlistOptions, cancellableOrigins);
116+
ConfigurableDependentPromise<U> result =
117+
new ConfigurableDependentPromise<>(original, defaultEnlistOptions, cancellableOrigins);
118+
113119
if (result.isCancelled()) {
114120
// Wrapped over already cancelled Promise
115121
// So result.cancel() has no effect
@@ -358,7 +364,9 @@ public <U> DependentPromise<U> thenComposeAsync(Function<? super T, ? extends Co
358364
return wrap(delegate.thenComposeAsync(fn), origin(enlistOrigin));
359365
}
360366

361-
public <U> DependentPromise<U> thenComposeAsync(Function<? super T, ? extends CompletionStage<U>> fn, Executor executor, boolean enlistOrigin) {
367+
public <U> DependentPromise<U> thenComposeAsync(Function<? super T, ? extends CompletionStage<U>> fn,
368+
Executor executor,
369+
boolean enlistOrigin) {
362370
return wrap(delegate.thenComposeAsync(fn, executor), origin(enlistOrigin));
363371
}
364372

@@ -389,11 +397,12 @@ public DependentPromise<T> exceptionallyComposeAsync(Function<Throwable, ? exten
389397
}
390398

391399
@Override
392-
public DependentPromise<T> exceptionallyComposeAsync(Function<Throwable, ? extends CompletionStage<T>> fn, Executor executor, boolean enlistOrigin) {
400+
public DependentPromise<T> exceptionallyComposeAsync(Function<Throwable, ? extends CompletionStage<T>> fn,
401+
Executor executor,
402+
boolean enlistOrigin) {
393403
return this.handleAsync(SharedFunctions.exceptionallyCompose(fn), executor, enlistOrigin)
394404
.thenCompose(Function.identity(), true);
395405
}
396-
397406

398407
public DependentPromise<T> whenComplete(BiConsumer<? super T, ? super Throwable> action, boolean enlistOrigin) {
399408
return wrap(delegate.whenComplete(action), origin(enlistOrigin));
@@ -403,7 +412,9 @@ public DependentPromise<T> whenCompleteAsync(BiConsumer<? super T, ? super Throw
403412
return wrap(delegate.whenCompleteAsync(action), origin(enlistOrigin));
404413
}
405414

406-
public DependentPromise<T> whenCompleteAsync(BiConsumer<? super T, ? super Throwable> action, Executor executor, boolean enlistOrigin) {
415+
public DependentPromise<T> whenCompleteAsync(BiConsumer<? super T, ? super Throwable> action,
416+
Executor executor,
417+
boolean enlistOrigin) {
407418
return wrap(delegate.whenCompleteAsync(action, executor), origin(enlistOrigin));
408419
}
409420

@@ -415,7 +426,9 @@ public <U> DependentPromise<U> handleAsync(BiFunction<? super T, Throwable, ? ex
415426
return wrap(delegate.handleAsync(fn), origin(enlistOrigin));
416427
}
417428

418-
public <U> DependentPromise<U> handleAsync(BiFunction<? super T, Throwable, ? extends U> fn, Executor executor, boolean enlistOrigin) {
429+
public <U> DependentPromise<U> handleAsync(BiFunction<? super T, Throwable, ? extends U> fn,
430+
Executor executor,
431+
boolean enlistOrigin) {
419432
return wrap(delegate.handleAsync(fn, executor), origin(enlistOrigin));
420433
}
421434

@@ -465,12 +478,14 @@ public DependentPromise<Void> thenRunAsync(Runnable action, Executor executor) {
465478
}
466479

467480
@Override
468-
public <U, V> DependentPromise<V> thenCombine(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) {
481+
public <U, V> DependentPromise<V> thenCombine(CompletionStage<? extends U> other,
482+
BiFunction<? super T, ? super U, ? extends V> fn) {
469483
return thenCombine(other, fn, defaultEnlistOptions);
470484
}
471485

472486
@Override
473-
public <U, V> DependentPromise<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) {
487+
public <U, V> DependentPromise<V> thenCombineAsync(CompletionStage<? extends U> other,
488+
BiFunction<? super T, ? super U, ? extends V> fn) {
474489
return thenCombineAsync(other, fn, defaultEnlistOptions);
475490
}
476491

@@ -483,12 +498,14 @@ public <U, V> DependentPromise<V> thenCombineAsync(CompletionStage<? extends U>
483498
}
484499

485500
@Override
486-
public <U> DependentPromise<Void> thenAcceptBoth(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action) {
501+
public <U> DependentPromise<Void> thenAcceptBoth(CompletionStage<? extends U> other,
502+
BiConsumer<? super T, ? super U> action) {
487503
return thenAcceptBoth(other, action, defaultEnlistOptions);
488504
}
489505

490506
@Override
491-
public <U> DependentPromise<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action) {
507+
public <U> DependentPromise<Void> thenAcceptBothAsync(CompletionStage<? extends U> other,
508+
BiConsumer<? super T, ? super U> action) {
492509
return thenAcceptBothAsync(other, action, defaultEnlistOptions);
493510
}
494511

src/main/java/net/tascalate/concurrent/ExecutorBoundCompletionStage.java

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,142 +36,175 @@ protected <U> CompletionStage<U> wrap(CompletionStage<U> original) {
3636
return new ExecutorBoundCompletionStage<>(original, defaultExecutor);
3737
}
3838

39+
@Override
3940
public <U> CompletionStage<U> thenApply(Function<? super T, ? extends U> fn) {
4041
return wrap(delegate.thenApply(fn));
4142
}
4243

44+
@Override
4345
public <U> CompletionStage<U> thenApplyAsync(Function<? super T, ? extends U> fn) {
4446
return thenApplyAsync(fn, defaultExecutor);
4547
}
4648

49+
@Override
4750
public <U> CompletionStage<U> thenApplyAsync(Function<? super T, ? extends U> fn, Executor executor) {
4851
return wrap(delegate.thenApplyAsync(fn, executor));
4952
}
5053

54+
@Override
5155
public CompletionStage<Void> thenAccept(Consumer<? super T> action) {
5256
return wrap(delegate.thenAccept(action));
5357
}
5458

59+
@Override
5560
public CompletionStage<Void> thenAcceptAsync(Consumer<? super T> action) {
5661
return thenAcceptAsync(action, defaultExecutor);
5762
}
5863

64+
@Override
5965
public CompletionStage<Void> thenAcceptAsync(Consumer<? super T> action, Executor executor) {
6066
return wrap(delegate.thenAcceptAsync(action, executor));
6167
}
6268

69+
@Override
6370
public CompletionStage<Void> thenRun(Runnable action) {
6471
return wrap(delegate.thenRun(action));
6572
}
6673

74+
@Override
6775
public CompletionStage<Void> thenRunAsync(Runnable action) {
6876
return thenRunAsync(action, defaultExecutor);
6977
}
7078

79+
@Override
7180
public CompletionStage<Void> thenRunAsync(Runnable action, Executor executor) {
7281
return wrap(delegate.thenRunAsync(action, executor));
7382
}
7483

84+
@Override
7585
public <U, V> CompletionStage<V> thenCombine(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) {
7686
return wrap(delegate.thenCombine(other, fn));
7787
}
7888

89+
@Override
7990
public <U, V> CompletionStage<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) {
8091
return thenCombineAsync(other, fn, defaultExecutor);
8192
}
8293

94+
@Override
8395
public <U, V> CompletionStage<V> thenCombineAsync(CompletionStage<? extends U> other,
84-
BiFunction<? super T, ? super U, ? extends V> fn,
85-
Executor executor) {
96+
BiFunction<? super T, ? super U, ? extends V> fn,
97+
Executor executor) {
8698

8799
return wrap(delegate.thenCombineAsync(other, fn, executor));
88100
}
89101

90-
public <U> CompletionStage<Void> thenAcceptBoth(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action) {
102+
@Override
103+
public <U> CompletionStage<Void> thenAcceptBoth(CompletionStage<? extends U> other,
104+
BiConsumer<? super T, ? super U> action) {
91105
return wrap(delegate.thenAcceptBoth(other, action));
92106
}
93107

94-
public <U> CompletionStage<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action) {
108+
@Override
109+
public <U> CompletionStage<Void> thenAcceptBothAsync(CompletionStage<? extends U> other,
110+
BiConsumer<? super T, ? super U> action) {
95111
return thenAcceptBothAsync(other, action, defaultExecutor);
96112
}
97113

114+
@Override
98115
public <U> CompletionStage<Void> thenAcceptBothAsync(CompletionStage<? extends U> other,
99-
BiConsumer<? super T, ? super U> action,
100-
Executor executor) {
116+
BiConsumer<? super T, ? super U> action,
117+
Executor executor) {
101118

102119
return wrap(delegate.thenAcceptBothAsync(other, action, executor));
103120
}
104121

122+
@Override
105123
public CompletionStage<Void> runAfterBoth(CompletionStage<?> other, Runnable action) {
106124
return wrap(delegate.runAfterBoth(other, action));
107125
}
108126

127+
@Override
109128
public CompletionStage<Void> runAfterBothAsync(CompletionStage<?> other, Runnable action) {
110129
return runAfterBothAsync(other, action, defaultExecutor);
111130
}
112131

132+
@Override
113133
public CompletionStage<Void> runAfterBothAsync(CompletionStage<?> other,
114-
Runnable action,
115-
Executor executor) {
134+
Runnable action,
135+
Executor executor) {
116136
return wrap(delegate.runAfterBothAsync(other, action, executor));
117137
}
118138

139+
@Override
119140
public <U> CompletionStage<U> applyToEither(CompletionStage<? extends T> other, Function<? super T, U> fn) {
120141
return wrap(delegate.applyToEither(other, fn));
121142
}
122143

144+
@Override
123145
public <U> CompletionStage<U> applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T, U> fn) {
124146
return applyToEitherAsync(other, fn, defaultExecutor);
125147
}
126148

149+
@Override
127150
public <U> CompletionStage<U> applyToEitherAsync(CompletionStage<? extends T> other,
128-
Function<? super T, U> fn,
129-
Executor executor) {
151+
Function<? super T, U> fn,
152+
Executor executor) {
130153

131154
return wrap(delegate.applyToEitherAsync(other, fn, executor));
132155
}
133156

157+
@Override
134158
public CompletionStage<Void> acceptEither(CompletionStage<? extends T> other, Consumer<? super T> action) {
135159
return wrap(delegate.acceptEither(other, action));
136160
}
137161

162+
@Override
138163
public CompletionStage<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action) {
139164
return acceptEitherAsync(other, action, defaultExecutor);
140165
}
141166

167+
@Override
142168
public CompletionStage<Void> acceptEitherAsync(CompletionStage<? extends T> other,
143-
Consumer<? super T> action,
144-
Executor executor) {
169+
Consumer<? super T> action,
170+
Executor executor) {
145171

146172
return wrap(delegate.acceptEitherAsync(other, action, executor));
147173
}
148174

175+
@Override
149176
public CompletionStage<Void> runAfterEither(CompletionStage<?> other, Runnable action) {
150177
return wrap(delegate.runAfterEither(other, action));
151178
}
152179

180+
@Override
153181
public CompletionStage<Void> runAfterEitherAsync(CompletionStage<?> other, Runnable action) {
154182
return runAfterEitherAsync(other, action, defaultExecutor);
155183
}
156184

185+
@Override
157186
public CompletionStage<Void> runAfterEitherAsync(CompletionStage<?> other,
158-
Runnable action,
159-
Executor executor) {
187+
Runnable action,
188+
Executor executor) {
160189
return wrap(delegate.runAfterEitherAsync(other, action, executor));
161190
}
162191

192+
@Override
163193
public <U> CompletionStage<U> thenCompose(Function<? super T, ? extends CompletionStage<U>> fn) {
164194
return wrap(delegate.thenCompose(fn));
165195
}
166196

197+
@Override
167198
public <U> CompletionStage<U> thenComposeAsync(Function<? super T, ? extends CompletionStage<U>> fn) {
168199
return thenComposeAsync(fn, defaultExecutor);
169200
}
170201

202+
@Override
171203
public <U> CompletionStage<U> thenComposeAsync(Function<? super T, ? extends CompletionStage<U>> fn, Executor executor) {
172204
return wrap(delegate.thenComposeAsync(fn, executor));
173205
}
174206

207+
@Override
175208
public CompletionStage<T> exceptionally(Function<Throwable, ? extends T> fn) {
176209
return wrap(delegate.exceptionally(fn));
177210
}

src/main/java/net/tascalate/concurrent/Promises.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -488,23 +488,28 @@ public static <T> Promise<List<T>> atLeast(int minResultsCount, int maxErrorsCou
488488
}
489489
}
490490

491-
public static <T> CompletionStage<T> exceptionallyApplyAsync(CompletionStage<? extends T> delegate, Function<Throwable, ? extends T> fn) {
491+
public static <T> CompletionStage<T> exceptionallyApplyAsync(CompletionStage<? extends T> delegate,
492+
Function<Throwable, ? extends T> fn) {
492493
return delegate.handleAsync(SharedFunctions.exceptionallyApply(fn));
493494
}
494495

495-
public static <T> CompletionStage<T> exceptionallyApplyAsync(CompletionStage<? extends T> delegate, Function<Throwable, ? extends T> fn, Executor executor) {
496+
public static <T> CompletionStage<T> exceptionallyApplyAsync(CompletionStage<? extends T> delegate,
497+
Function<Throwable, ? extends T> fn, Executor executor) {
496498
return delegate.handleAsync(SharedFunctions.exceptionallyApply(fn), executor);
497499
}
498500

499-
public static <T> Promise<T> exceptionallyCompose(CompletionStage<? extends T> delegate, Function<Throwable, ? extends CompletionStage<T>> fn) {
501+
public static <T> Promise<T> exceptionallyCompose(CompletionStage<? extends T> delegate,
502+
Function<Throwable, ? extends CompletionStage<T>> fn) {
500503
return flatMap( delegate.handle(SharedFunctions.exceptionallyCompose(fn)) );
501504
}
502505

503-
public static <T> Promise<T> exceptionallyComposeAsync(CompletionStage<? extends T> delegate, Function<Throwable, ? extends CompletionStage<T>> fn) {
506+
public static <T> Promise<T> exceptionallyComposeAsync(CompletionStage<? extends T> delegate,
507+
Function<Throwable, ? extends CompletionStage<T>> fn) {
504508
return flatMap( delegate.handleAsync(SharedFunctions.exceptionallyCompose(fn)) );
505509
}
506510

507-
public static <T> Promise<T> exceptionallyComposeAsync(CompletionStage<? extends T> delegate, Function<Throwable, ? extends CompletionStage<T>> fn, Executor executor) {
511+
public static <T> Promise<T> exceptionallyComposeAsync(CompletionStage<? extends T> delegate,
512+
Function<Throwable, ? extends CompletionStage<T>> fn, Executor executor) {
508513
return flatMap( delegate.handleAsync(SharedFunctions.exceptionallyCompose(fn), executor) );
509514
}
510515

src/main/java/net/tascalate/concurrent/decorators/ExecutorBoundDependentPromise.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ public <U> DependentPromise<Void> thenAcceptBothAsync(CompletionStage<? extends
8888
}
8989

9090
@Override
91-
public DependentPromise<Void> runAfterBothAsync(CompletionStage<?> other, Runnable action, Set<PromiseOrigin> enlistOptions) {
91+
public DependentPromise<Void> runAfterBothAsync(CompletionStage<?> other,
92+
Runnable action,
93+
Set<PromiseOrigin> enlistOptions) {
9294
return runAfterBothAsync(other, action, defaultExecutor, enlistOptions);
9395
}
9496

@@ -107,7 +109,9 @@ public DependentPromise<Void> acceptEitherAsync(CompletionStage<? extends T> oth
107109
}
108110

109111
@Override
110-
public DependentPromise<Void> runAfterEitherAsync(CompletionStage<?> other, Runnable action, Set<PromiseOrigin> enlistOptions) {
112+
public DependentPromise<Void> runAfterEitherAsync(CompletionStage<?> other,
113+
Runnable action,
114+
Set<PromiseOrigin> enlistOptions) {
111115
return runAfterEitherAsync(other, action, defaultExecutor, enlistOptions);
112116
}
113117

@@ -142,12 +146,14 @@ public DependentPromise<Void> thenRunAsync(Runnable action) {
142146
}
143147

144148
@Override
145-
public <U, V> DependentPromise<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) {
149+
public <U, V> DependentPromise<V> thenCombineAsync(CompletionStage<? extends U> other,
150+
BiFunction<? super T, ? super U, ? extends V> fn) {
146151
return thenCombineAsync(other, fn, defaultExecutor);
147152
}
148153

149154
@Override
150-
public <U> DependentPromise<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action) {
155+
public <U> DependentPromise<Void> thenAcceptBothAsync(CompletionStage<? extends U> other,
156+
BiConsumer<? super T, ? super U> action) {
151157
return thenAcceptBothAsync(other, action, defaultExecutor);
152158
}
153159

0 commit comments

Comments
 (0)