Search in sources :

Example 6 with Nullable

use of io.reactivex.annotations.Nullable in project RxJava by ReactiveX.

the class ObservableObserveOnTest method nonFusedPollThrows.

@Test
public void nonFusedPollThrows() {
    new Observable<Integer>() {

        @Override
        protected void subscribeActual(Observer<? super Integer> observer) {
            observer.onSubscribe(Disposables.empty());
            @SuppressWarnings("unchecked") ObserveOnObserver<Integer> oo = (ObserveOnObserver<Integer>) observer;
            oo.queue = new SimpleQueue<Integer>() {

                @Override
                public boolean offer(Integer value) {
                    return false;
                }

                @Override
                public boolean offer(Integer v1, Integer v2) {
                    return false;
                }

                @Nullable
                @Override
                public Integer poll() throws Exception {
                    throw new TestException();
                }

                @Override
                public boolean isEmpty() {
                    return false;
                }

                @Override
                public void clear() {
                }
            };
            oo.clear();
            oo.schedule();
        }
    }.observeOn(Schedulers.single()).test().awaitDone(5, TimeUnit.SECONDS).assertFailure(TestException.class);
}
Also used : TestException(io.reactivex.exceptions.TestException) ObserveOnObserver(io.reactivex.internal.operators.observable.ObservableObserveOn.ObserveOnObserver) Observer(io.reactivex.Observer) ObserveOnObserver(io.reactivex.internal.operators.observable.ObservableObserveOn.ObserveOnObserver) Observable(io.reactivex.Observable) Nullable(io.reactivex.annotations.Nullable) TestException(io.reactivex.exceptions.TestException) Test(org.junit.Test)

Example 7 with Nullable

use of io.reactivex.annotations.Nullable in project XChange by knowm.

the class BitfinexStreamingAdapters method adaptPreTrade.

@Nullable
static BitfinexWebSocketAuthPreTrade adaptPreTrade(JsonNode preTrade) {
    if (preTrade.size() < 12) {
        LOG.error("addPreTrade unexpected record size={}, record={}", preTrade.size(), preTrade.toString());
        return null;
    }
    long id = preTrade.get(0).longValue();
    String pair = preTrade.get(1).textValue();
    long mtsCreate = preTrade.get(2).longValue();
    long orderId = preTrade.get(3).longValue();
    BigDecimal execAmount = preTrade.get(4).decimalValue();
    BigDecimal execPrice = preTrade.get(5).decimalValue();
    String orderType = preTrade.get(6).textValue();
    BigDecimal orderPrice = preTrade.get(7).decimalValue();
    int maker = preTrade.get(8).intValue();
    BitfinexWebSocketAuthPreTrade preTradeObject = new BitfinexWebSocketAuthPreTrade(id, pair, mtsCreate, orderId, execAmount, execPrice, orderType, orderPrice, maker);
    LOG.debug("New pre trade: {}", preTradeObject);
    return preTradeObject;
}
Also used : BitfinexWebSocketAuthPreTrade(info.bitrich.xchangestream.bitfinex.dto.BitfinexWebSocketAuthPreTrade) BigDecimal(java.math.BigDecimal) Nullable(io.reactivex.annotations.Nullable)

Example 8 with Nullable

use of io.reactivex.annotations.Nullable in project XChange by knowm.

the class BitfinexStreamingAdapters method createBalanceObject.

@Nullable
private static BitfinexWebSocketAuthBalance createBalanceObject(JsonNode balance) {
    if (balance.size() < 5) {
        LOG.error("createBalanceObject unexpected record size={}, record={}", balance.size(), balance.toString());
        return null;
    }
    String walletType = balance.get(0).textValue();
    String currency = balance.get(1).textValue();
    BigDecimal balanceValue = balance.get(2).decimalValue();
    BigDecimal unsettledInterest = balance.get(3).decimalValue();
    BigDecimal balanceAvailable = balance.get(4).asText().equals("null") ? null : balance.get(4).decimalValue();
    return new BitfinexWebSocketAuthBalance(walletType, currency, balanceValue, unsettledInterest, balanceAvailable);
}
Also used : BitfinexWebSocketAuthBalance(info.bitrich.xchangestream.bitfinex.dto.BitfinexWebSocketAuthBalance) BigDecimal(java.math.BigDecimal) Nullable(io.reactivex.annotations.Nullable)

Example 9 with Nullable

use of io.reactivex.annotations.Nullable in project XChange by knowm.

the class BitfinexStreamingAdapters method adaptTrade.

@Nullable
static BitfinexWebSocketAuthTrade adaptTrade(JsonNode trade) {
    if (trade.size() < 11) {
        LOG.error("addTrade unexpected record size={}, record={}", trade.size(), trade.toString());
        return null;
    }
    long id = trade.get(0).longValue();
    String pair = trade.get(1).textValue();
    long mtsCreate = trade.get(2).longValue();
    long orderId = trade.get(3).longValue();
    BigDecimal execAmount = trade.get(4).decimalValue();
    BigDecimal execPrice = trade.get(5).decimalValue();
    String orderType = trade.get(6).textValue();
    BigDecimal orderPrice = trade.get(7).decimalValue();
    int maker = trade.get(8).intValue();
    BigDecimal fee = trade.get(9).decimalValue();
    String currency = trade.get(10).textValue();
    BitfinexWebSocketAuthTrade tradeObject = new BitfinexWebSocketAuthTrade(id, pair, mtsCreate, orderId, execAmount, execPrice, orderType, orderPrice, maker, fee, currency);
    LOG.debug("New trade: {}", tradeObject);
    return tradeObject;
}
Also used : BitfinexWebSocketAuthTrade(info.bitrich.xchangestream.bitfinex.dto.BitfinexWebSocketAuthTrade) BigDecimal(java.math.BigDecimal) Nullable(io.reactivex.annotations.Nullable)

Example 10 with Nullable

use of io.reactivex.annotations.Nullable in project XChange by knowm.

the class BitfinexStreamingAdapters method adaptOrder.

@Nullable
static BitfinexWebSocketAuthOrder adaptOrder(JsonNode order) {
    BitfinexWebSocketAuthOrder orderObject = createOrderObject(order);
    if (orderObject == null) {
        return null;
    }
    LOG.debug("Updated order: {}", orderObject);
    return orderObject;
}
Also used : BitfinexWebSocketAuthOrder(info.bitrich.xchangestream.bitfinex.dto.BitfinexWebSocketAuthOrder) Nullable(io.reactivex.annotations.Nullable)

Aggregations

Nullable (io.reactivex.annotations.Nullable)11 BigDecimal (java.math.BigDecimal)4 Test (org.junit.Test)3 Location (android.location.Location)2 BitfinexWebSocketAuthBalance (info.bitrich.xchangestream.bitfinex.dto.BitfinexWebSocketAuthBalance)2 BitfinexWebSocketAuthOrder (info.bitrich.xchangestream.bitfinex.dto.BitfinexWebSocketAuthOrder)2 BaseObserveOnSubscriber (io.reactivex.internal.operators.flowable.FlowableObserveOn.BaseObserveOnSubscriber)2 BooleanSubscription (io.reactivex.internal.subscriptions.BooleanSubscription)2 BitfinexWebSocketAuthPreTrade (info.bitrich.xchangestream.bitfinex.dto.BitfinexWebSocketAuthPreTrade)1 BitfinexWebSocketAuthTrade (info.bitrich.xchangestream.bitfinex.dto.BitfinexWebSocketAuthTrade)1 Observable (io.reactivex.Observable)1 Observer (io.reactivex.Observer)1 TestException (io.reactivex.exceptions.TestException)1 ObserveOnObserver (io.reactivex.internal.operators.observable.ObservableObserveOn.ObserveOnObserver)1