MCPcopy Create free account
hub / github.com/traneio/future / apply

Method apply

future-java/src/main/java/io/trane/future/Promise.java:38–64  ·  view source on GitHub ↗

Creates a promise that triggers the provided handlers in case it receives an interrupt. @param handlers the list of handlers to be triggered. @return the new promise instance.

(final List<? extends InterruptHandler> handlers)

Source from the content-addressed store, hash-verified

36 * @return the new promise instance.
37 */
38 public static final <T> Promise<T> apply(final List<? extends InterruptHandler> handlers) {
39 final Optional<?>[] savedContext = Local.save();
40 if (savedContext.length == 0)
41 return new Promise<T>() {
42 @Override
43 protected final Optional<?>[] getSavedContext() {
44 return Local.EMPTY;
45 }
46
47 @Override
48 protected final InterruptHandler getInterruptHandler() {
49 return InterruptHandler.apply(handlers);
50 }
51 };
52 else
53 return new Promise<T>() {
54 @Override
55 protected final Optional<?>[] getSavedContext() {
56 return savedContext;
57 }
58
59 @Override
60 protected final InterruptHandler getInterruptHandler() {
61 return InterruptHandler.apply(handlers);
62 }
63 };
64 }
65
66 /**
67 * Creates a promise that triggers the provided handler in case it receives an

Callers 15

proxyMethod · 0.95
proxyToSuccessMethod · 0.95
proxyToFailureMethod · 0.95
applyMethod · 0.95
applyWithLocalMethod · 0.95
applyHandlerMethod · 0.95
applyHandlerWithLocalMethod · 0.95
applyTwoHandlersMethod · 0.95
applyHandlersMethod · 0.95

Calls 1

saveMethod · 0.95

Tested by 15

proxyMethod · 0.76
proxyToSuccessMethod · 0.76
proxyToFailureMethod · 0.76
applyMethod · 0.76
applyWithLocalMethod · 0.76
applyHandlerMethod · 0.76
applyHandlerWithLocalMethod · 0.76
applyTwoHandlersMethod · 0.76
applyHandlersMethod · 0.76