@Override @SuppressWarnings("unchecked") public Object apply(Object obj, Type targetType) throws Exception { if (from instanceof Class) { Class< ? > cls = (Class< ? >) from; if (cls.isInstance(obj)) { T res = func.apply((F) obj); if (res != null) return res; else return ConverterFunction.CANNOT_HANDLE; } } return ConverterFunction.CANNOT_HANDLE; } };
@Override @SuppressWarnings("unchecked") public Object apply(Object obj, Type targetType) throws Exception { if (from instanceof Class) { Class< ? > cls = (Class< ? >) from; if (cls.isInstance(obj)) { T res = func.apply((F) obj); if (res != null) return res; else return ConverterFunction.CANNOT_HANDLE; } } return ConverterFunction.CANNOT_HANDLE; } };
@Override @SuppressWarnings("unchecked") public Object apply(Object obj, Type targetType) throws Exception { if (from instanceof Class) { Class< ? > cls = (Class< ? >) from; if (cls.isInstance(obj)) { T res = func.apply((F) obj); if (res != null) return res; else return ConverterFunction.CANNOT_HANDLE; } } return ConverterFunction.CANNOT_HANDLE; } };
@Override @SuppressWarnings("unchecked") public Object apply(Object obj, Type targetType) throws Exception { if (from instanceof Class) { Class< ? > cls = (Class< ? >) from; if (cls.isInstance(obj)) { T res = func.apply((F) obj); if (res != null) return res; else return ConverterFunction.CANNOT_HANDLE; } } return ConverterFunction.CANNOT_HANDLE; } };
@Override @SuppressWarnings("unchecked") public Object apply(Object obj, Type targetType) throws Exception { if (from instanceof Class) { Class< ? > cls = (Class< ? >) from; if (cls.isInstance(obj)) { T res = func.apply((F) obj); if (res != null) return res; else return ConverterFunction.CANNOT_HANDLE; } } return ConverterFunction.CANNOT_HANDLE; } };
@Override public <R> PushStream<R> window(Duration time, Executor executor, Function<Collection<T>,R> f) { return window(() -> time, () -> 0, executor, (t, c) -> { try { return f.apply(c); } catch (Exception e) { throw new RuntimeException(e); } }); }
@SuppressWarnings("unchecked") public Promise<R> call(Promise<T> resolved) throws Exception { return (Promise<R>) mapper.apply(resolved.getValue()); } }
@Override public <R> PushStream<R> window(Duration time, Executor executor, Function<Collection<T>,R> f) { return window(() -> time, () -> 0, executor, (t, c) -> { try { return f.apply(c); } catch (Exception e) { throw new RuntimeException(e); } }); }
@Override @SuppressWarnings("unchecked") public Object apply(Object obj, Type targetType) throws Exception { Rule< ? , ? > r = Rule.this; Type type = ((ParameterizedType) r.getClass() .getGenericSuperclass()).getActualTypeArguments()[0]; if (type instanceof ParameterizedType) { type = ((ParameterizedType) type).getRawType(); } Class< ? > cls = null; if (type instanceof Class) { cls = ((Class< ? >) type); } else { return ConverterFunction.CANNOT_HANDLE; } if (cls.isInstance(obj)) { return func.apply((F) obj); } return ConverterFunction.CANNOT_HANDLE; } };
@Override public <R> PushStream<R> window(Duration time, Executor executor, Function<Collection<T>,R> f) { return window(() -> time, () -> 0, executor, (t, c) -> { try { return f.apply(c); } catch (Exception e) { throw new RuntimeException(e); } }); }
@Override @SuppressWarnings("unchecked") public Object apply(Object obj, Type targetType) throws Exception { Rule< ? , ? > r = Rule.this; Type type = ((ParameterizedType) r.getClass() .getGenericSuperclass()).getActualTypeArguments()[0]; if (type instanceof ParameterizedType) { type = ((ParameterizedType) type).getRawType(); } Class< ? > cls = null; if (type instanceof Class) { cls = ((Class< ? >) type); } else { return ConverterFunction.CANNOT_HANDLE; } if (cls.isInstance(obj)) { return func.apply((F) obj); } return ConverterFunction.CANNOT_HANDLE; } };
@Override @SuppressWarnings("unchecked") public Object apply(Object obj, Type targetType) throws Exception { Rule< ? , ? > r = Rule.this; Type type = ((ParameterizedType) r.getClass() .getGenericSuperclass()).getActualTypeArguments()[0]; if (type instanceof ParameterizedType) { type = ((ParameterizedType) type).getRawType(); } Class< ? > cls = null; if (type instanceof Class) { cls = ((Class< ? >) type); } else { return ConverterFunction.CANNOT_HANDLE; } if (cls.isInstance(obj)) { return func.apply((F) obj); } return ConverterFunction.CANNOT_HANDLE; } };
@Override @SuppressWarnings("unchecked") public Object apply(Object obj, Type targetType) throws Exception { Rule< ? , ? > r = Rule.this; Type type = ((ParameterizedType) r.getClass() .getGenericSuperclass()).getActualTypeArguments()[0]; if (type instanceof ParameterizedType) { type = ((ParameterizedType) type).getRawType(); } Class< ? > cls = null; if (type instanceof Class) { cls = ((Class< ? >) type); } else { return ConverterFunction.CANNOT_HANDLE; } if (cls.isInstance(obj)) { return func.apply((F) obj); } return ConverterFunction.CANNOT_HANDLE; } };
@Override @SuppressWarnings("unchecked") public Object apply(Object obj, Type targetType) throws Exception { Rule< ? , ? > r = Rule.this; Type type = ((ParameterizedType) r.getClass() .getGenericSuperclass()).getActualTypeArguments()[0]; if (type instanceof ParameterizedType) { type = ((ParameterizedType) type).getRawType(); } Class< ? > cls = null; if (type instanceof Class) { cls = ((Class< ? >) type); } else { return ConverterFunction.CANNOT_HANDLE; } if (cls.isInstance(obj)) { return func.apply((F) obj); } return ConverterFunction.CANNOT_HANDLE; } };
public Promise<R> call(Promise<T> resolved) throws Exception { return new PromiseImpl<R>(mapper.apply(resolved.getValue()), null); } }
@Override public Promise<T> call(Promise<T> resolved) throws Exception { try { Promise<? extends R> p = mapper.apply(resolved.getValue()); result.resolveWith(p); } catch (Throwable t) { result.fail(t); } return null; } }, new Failure() {
@Override public Promise<T> call(Promise<T> resolved) throws Exception { try { R val = mapper.apply(resolved.getValue()); result.resolve(val); } catch (Throwable t) { result.fail(t); } return null; } }, new Failure() {
private <R> long aggregateAndForward(Function<Collection<T>,R> f, AbstractPushStreamImpl<R> eventStream, PushEvent< ? extends T> event, Queue<T> queue) throws Exception { if (!queue.offer(event.getData())) { ((ArrayQueue<T>) queue).forcePush(event.getData()); } return eventStream.handleEvent(PushEvent.data(f.apply(queue))); }
private <R> long aggregateAndForward(Function<Collection<T>,R> f, AbstractPushStreamImpl<R> eventStream, PushEvent< ? extends T> event, Queue<T> queue) throws Exception { if (!queue.offer(event.getData())) { ((ArrayQueue<T>) queue).forcePush(event.getData()); } return eventStream.handleEvent(PushEvent.data(f.apply(queue))); }
private <R> long aggregateAndForward(Function<Collection<T>,R> f, AbstractPushStreamImpl<R> eventStream, PushEvent< ? extends T> event, Queue<T> queue) throws Exception { if (!queue.offer(event.getData())) { ((ArrayQueue<T>) queue).forcePush(event.getData()); } return eventStream.handleEvent(PushEvent.data(f.apply(queue))); }