quark._CallbackEvent Maven / Gradle / Ivy
/* Quark 1.0.452 run at 2016-11-11 16:09:46.008093 */
package quark;
public class _CallbackEvent implements quark.concurrent.Event, io.datawire.quark.runtime.QObject {
public static quark.reflect.Class quark__CallbackEvent_ref = datawire_mdk_md.Root.quark__CallbackEvent_md;
public UnaryCallable _callable;
public Promise _next;
public Object _value;
public _Callback _callback;
public _CallbackEvent(UnaryCallable callable, Promise next, Object value, _Callback callback) {
(this)._callable = callable;
(this)._next = next;
(this)._value = value;
(this)._callback = callback;
}
public quark.concurrent.EventContext getContext() {
return (this)._callback;
}
public static void fullfilPromise(Promise promise, Object value) {
if ((quark.reflect.Class.ERROR).hasInstance(value)) {
(promise)._reject((quark.error.Error) (value));
} else {
(promise)._resolve(value);
}
}
public void fireEvent() {
Object result = ((this)._callable).call((this)._value);
if ((quark.reflect.Class.get("quark.Promise")).hasInstance(result)) {
Promise toChain = (Promise) (result);
(toChain).andFinally(new _ChainPromise((this)._next));
} else {
_CallbackEvent.fullfilPromise((this)._next, result);
}
}
public String _getClass() {
return "quark._CallbackEvent";
}
public Object _getField(String name) {
if ((name)==("_callable") || ((Object)(name) != null && ((Object) (name)).equals("_callable"))) {
return (this)._callable;
}
if ((name)==("_next") || ((Object)(name) != null && ((Object) (name)).equals("_next"))) {
return (this)._next;
}
if ((name)==("_value") || ((Object)(name) != null && ((Object) (name)).equals("_value"))) {
return (this)._value;
}
if ((name)==("_callback") || ((Object)(name) != null && ((Object) (name)).equals("_callback"))) {
return (this)._callback;
}
return null;
}
public void _setField(String name, Object value) {
if ((name)==("_callable") || ((Object)(name) != null && ((Object) (name)).equals("_callable"))) {
(this)._callable = (UnaryCallable) (value);
}
if ((name)==("_next") || ((Object)(name) != null && ((Object) (name)).equals("_next"))) {
(this)._next = (Promise) (value);
}
if ((name)==("_value") || ((Object)(name) != null && ((Object) (name)).equals("_value"))) {
(this)._value = value;
}
if ((name)==("_callback") || ((Object)(name) != null && ((Object) (name)).equals("_callback"))) {
(this)._callback = (_Callback) (value);
}
}
}