
com.darylteo.vertx.promises.java.Promise Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vertx-promises-java Show documentation
Show all versions of vertx-promises-java Show documentation
Promises module for Vert.x - java
The newest version!
package com.darylteo.vertx.promises.java;
import java.util.LinkedHashMap;
import org.vertx.java.core.Handler;
import rx.Observer;
import rx.Subscription;
import rx.util.functions.Function;
import com.darylteo.rx.promises.AbstractPromise;
import com.darylteo.vertx.promises.java.functions.FinallyAction;
import com.darylteo.vertx.promises.java.functions.FinallyFunction;
import com.darylteo.vertx.promises.java.functions.PromiseAction;
import com.darylteo.vertx.promises.java.functions.PromiseFunction;
import com.darylteo.vertx.promises.java.functions.RepromiseFunction;
public class Promise extends AbstractPromise implements Handler {
public static Promise defer() {
return new Promise();
}
public Promise() {
super(new LinkedHashMap>());
}
/* ================== */
/* Strictly Typed Defer Methods */
// then(onFulfilled)
public Promise then(PromiseFunction onFulfilled) {
return this.promise(onFulfilled, null, null);
}
public Promise then(RepromiseFunction onFulfilled) {
return this.promise(onFulfilled, null, null);
}
public Promise then(PromiseAction onFulfilled) {
return this.promise(onFulfilled, null, null);
}
// then(onFulfilled, onRejected)
public Promise then(PromiseFunction onFulfilled,
PromiseFunction onRejected) {
return this.promise(onFulfilled, onRejected, null);
}
public Promise then(PromiseFunction onFulfilled,
RepromiseFunction onRejected) {
return this.promise(onFulfilled, onRejected, null);
}
public Promise then(PromiseFunction onFulfilled,
PromiseAction onRejected) {
return this.promise(onFulfilled, onRejected, null);
}
public Promise then(RepromiseFunction onFulfilled,
PromiseFunction onRejected) {
return this.promise(onFulfilled, onRejected, null);
}
public Promise then(RepromiseFunction onFulfilled,
RepromiseFunction onRejected) {
return this.promise(onFulfilled, onRejected, null);
}
public Promise then(RepromiseFunction onFulfilled,
PromiseAction onRejected) {
return this.promise(onFulfilled, onRejected, null);
}
public Promise then(PromiseAction onFulfilled,
PromiseAction onRejected) {
return this.promise(onFulfilled, onRejected, null);
}
// fail(onRejected)
public Promise fail(PromiseFunction onRejected) {
return this.promise(null, onRejected, null);
}
public Promise fail(RepromiseFunction onRejected) {
return this.promise(null, onRejected, null);
}
public Promise fail(PromiseAction onRejected) {
return this.promise(null, onRejected, null);
}
// fin(onFinally)
public Promise fin(FinallyFunction> onFinally) {
return this.promise(null, null, onFinally);
}
public Promise fin(FinallyAction onFinally) {
return this.promise(null, null, onFinally);
}
@SuppressWarnings("unchecked")
protected Promise promise(Function onFulfilled, Function onRejected, Function onFinally) {
return (Promise) super._then(onFulfilled, onRejected, onFinally);
}
@Override
public void handle(T event) {
this.fulfill(event);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy