Search in sources :

Example 1 with ProtobufferException

use of bisq.common.proto.ProtobufferException in project bisq-core by bisq-network.

the class TradableList method fromProto.

@Nullable
public static TradableList fromProto(PB.TradableList proto, CoreProtoResolver coreProtoResolver, Storage<TradableList<Tradable>> storage, BtcWalletService btcWalletService) {
    log.debug("TradableList fromProto of {} ", proto);
    List<Tradable> list = proto.getTradableList().stream().map(tradable -> {
        switch(tradable.getMessageCase()) {
            case OPEN_OFFER:
                return OpenOffer.fromProto(tradable.getOpenOffer());
            case BUYER_AS_MAKER_TRADE:
                return BuyerAsMakerTrade.fromProto(tradable.getBuyerAsMakerTrade(), storage, btcWalletService, coreProtoResolver);
            case BUYER_AS_TAKER_TRADE:
                return BuyerAsTakerTrade.fromProto(tradable.getBuyerAsTakerTrade(), storage, btcWalletService, coreProtoResolver);
            case SELLER_AS_MAKER_TRADE:
                return SellerAsMakerTrade.fromProto(tradable.getSellerAsMakerTrade(), storage, btcWalletService, coreProtoResolver);
            case SELLER_AS_TAKER_TRADE:
                return SellerAsTakerTrade.fromProto(tradable.getSellerAsTakerTrade(), storage, btcWalletService, coreProtoResolver);
            default:
                log.error("Unknown messageCase. tradable.getMessageCase() = " + tradable.getMessageCase());
                throw new ProtobufferException("Unknown messageCase. tradable.getMessageCase() = " + tradable.getMessageCase());
        }
    }).collect(Collectors.toList());
    return new TradableList<>(storage, list);
}
Also used : BtcWalletService(bisq.core.btc.wallet.BtcWalletService) ProtoUtil(bisq.common.proto.ProtoUtil) PersistableEnvelope(bisq.common.proto.persistable.PersistableEnvelope) Getter(lombok.Getter) OpenOffer(bisq.core.offer.OpenOffer) FXCollections(javafx.collections.FXCollections) Collectors(java.util.stream.Collectors) ProtobufferException(bisq.common.proto.ProtobufferException) ArrayList(java.util.ArrayList) CoreProtoResolver(bisq.core.proto.CoreProtoResolver) Consumer(java.util.function.Consumer) PB(io.bisq.generated.protobuffer.PB) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) Stream(java.util.stream.Stream) Storage(bisq.common.storage.Storage) Message(com.google.protobuf.Message) ObservableList(javafx.collections.ObservableList) Nullable(javax.annotation.Nullable) ProtobufferException(bisq.common.proto.ProtobufferException) Nullable(javax.annotation.Nullable)

Aggregations

ProtoUtil (bisq.common.proto.ProtoUtil)1 ProtobufferException (bisq.common.proto.ProtobufferException)1 PersistableEnvelope (bisq.common.proto.persistable.PersistableEnvelope)1 Storage (bisq.common.storage.Storage)1 BtcWalletService (bisq.core.btc.wallet.BtcWalletService)1 OpenOffer (bisq.core.offer.OpenOffer)1 CoreProtoResolver (bisq.core.proto.CoreProtoResolver)1 Message (com.google.protobuf.Message)1 PB (io.bisq.generated.protobuffer.PB)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 FXCollections (javafx.collections.FXCollections)1 ObservableList (javafx.collections.ObservableList)1 Nullable (javax.annotation.Nullable)1 Getter (lombok.Getter)1 Slf4j (lombok.extern.slf4j.Slf4j)1