@Override public void onNext(T t) { try { addNext(t); } catch (MissingBackpressureException e) { throw Exceptions.propagate(e); } }
@Override public SSLEngine call(ByteBufAllocator allocator) { try { return SslContextBuilder.forClient() .trustManager(InsecureTrustManagerFactory.INSTANCE) .build() .newEngine(allocator); } catch (Exception e) { throw Exceptions.propagate(e); } } }));
@Override public String call(String s) { try { isContainsBadWord(s); return s; } catch (Throwable t) { throw Exceptions.propagate(t); } } };
private Notification<? extends T> take() { try { return notifications.take(); } catch (InterruptedException e) { throw Exceptions.propagate(e); } }
@Override public byte[] call(InputStream inputStream) { try { return ByteStreams.toByteArray(inputStream); } catch (IOException e) { throw Exceptions.propagate(e); } } });
@Override public byte[] call(InputStream inputStream) { try { return ByteStreams.toByteArray(inputStream); } catch (IOException e) { throw Exceptions.propagate(e); } } });
@Override public boolean add(Runnable r) { try (Context time = waitTime.time()) { this.put(r); return true; } catch (InterruptedException e) { throw Exceptions.propagate(e); } }
@Override public byte[] call(ResponseBody responseBody) { try { return responseBody.bytes(); } catch (IOException e) { throw Exceptions.propagate(e); } } });
@Override public boolean offer(Runnable r) { try (Context time = waitTime.time()) { this.put(r); return true; } catch (InterruptedException e) { throw Exceptions.propagate(e); } }
@Override public <T> Observable<T> fromJson(Class<T> clazz) { return asString().map(json -> { try { return jsonMapper.readValue(json, clazz); } catch (IOException e) { throw Exceptions.propagate(e); } }); } }
@Override public byte[] call(ResponseBody responseBody) { try { return responseBody.bytes(); } catch (IOException e) { throw Exceptions.propagate(e); } } });
@Override public byte[] call(ResponseBody responseBody) { try { return responseBody.bytes(); } catch (IOException e) { throw Exceptions.propagate(e); } } });
private static <U> U getDataSnapshotTypedValue(DataSnapshot dataSnapshot, Class<U> clazz) { U value = dataSnapshot.getValue(clazz); if (value == null) { throw Exceptions.propagate(new RxFirebaseDataCastException( "unable to cast firebase data response to " + clazz.getSimpleName())); } return value; }
@Override public Void call() throws Exception { observer.await(); Throwable t = observer.getThrowable(); if (t != null) { throw Exceptions.propagate(t); } return null; } }
@Override public Void call() throws Exception { observer.await(); Throwable t = observer.getThrowable(); if (t != null) { throw Exceptions.propagate(t); } return null; } }
@Override public Single<T> getById(String id){ try { return Single.just(genericDao.getById(id)).map(o->{ if(o == null) throw Exceptions.propagate(new ResourceNotFoundException(type.getSimpleName() + " : " + id)); return o; }); } catch (DataAccessException de) { return Single.error(de); } }
@Override public SSLEngine call(ByteBufAllocator allocator) { SelfSignedCertificate ssc; try { ssc = new SelfSignedCertificate(); return SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()) .build() .newEngine(allocator); } catch (Exception e) { throw Exceptions.propagate(e); } } }));
@Override public boolean hasNext() { if (buf == null) { buf = take(); } if (buf.isOnError()) { throw Exceptions.propagate(buf.getThrowable()); } return !buf.isOnCompleted(); }
@Override public RxFirebaseChildEvent<U> call(final RxFirebaseChildEvent<DataSnapshot> rxFirebaseChildEvent) { DataSnapshot dataSnapshot = rxFirebaseChildEvent.getValue(); if (dataSnapshot.exists()) { return new RxFirebaseChildEvent<U>( dataSnapshot.getKey(), getDataSnapshotTypedValue(dataSnapshot, clazz), rxFirebaseChildEvent.getPreviousChildName(), rxFirebaseChildEvent.getEventType()); } else { throw Exceptions.propagate(new RuntimeException("child dataSnapshot doesn't exist")); } } }