Package com.fasterxml.jackson.databind.type

Examples of com.fasterxml.jackson.databind.type.CollectionType


        }
        if (type != null) {
            clazz = exchange.getContext().getClassResolver().resolveMandatoryClass(type);
        }
        if (collectionType != null) {
            CollectionType collType = objectMapper.getTypeFactory().constructCollectionType(collectionType, clazz);
            return this.objectMapper.readValue(stream, collType);
        } else {
            return this.objectMapper.readValue(stream, clazz);
        }
    }
View Full Code Here


  }

  @Override
  @SuppressWarnings({"unchecked"})
  public <T extends Collection<E>, E> T convertValue(Object fromValue, Class<T> collectionType, Class<E> elementType) throws IllegalArgumentException {
      CollectionType colType = objectMapper.getTypeFactory().constructCollectionType(collectionType, elementType);

      return (T)objectMapper.convertValue(fromValue, colType);
  }
View Full Code Here

    {
        JavaType t;

        TypeFactory tf = TypeFactory.defaultInstance();
        t = tf.constructType(new TypeReference<MyLongList<Integer>>() {});
        CollectionType type = (CollectionType) t;
        assertSame(MyLongList.class, type.getRawClass());
        assertEquals(tf.constructType(Long.class), type.getContentType());       

        t = tf.constructType(LongList.class);
        type = (CollectionType) t;
        assertSame(LongList.class, type.getRawClass());
        assertEquals(tf.constructType(Long.class), type.getContentType());       
    }
View Full Code Here

    // Read in the JSON from the example resources
    final InputStream is = JustcoinTradesTest.class.getResourceAsStream("/marketdata/example-trades-data.json");

    // Use Jackson to parse it
    final ObjectMapper mapper = new ObjectMapper();
    CollectionType collectionType = mapper.getTypeFactory().constructCollectionType(List.class, JustcoinPublicTrade.class);
    final List<JustcoinPublicTrade> trades = mapper.readValue(is, collectionType);

    // Verify that the example data was unmarshalled correctly
    assertThat(trades).hasSize(2);
    final JustcoinPublicTrade trade = trades.get(0);
View Full Code Here

    // Read in the JSON from the example resources
    final InputStream is = JustcoinTradesTest.class.getResourceAsStream("/marketdata/example-trades-data.json");

    // Use Jackson to parse it
    final ObjectMapper mapper = new ObjectMapper();
    CollectionType collectionType = mapper.getTypeFactory().constructCollectionType(List.class, JustcoinPublicTrade.class);
    final List<JustcoinPublicTrade> trades = mapper.readValue(is, collectionType);

    final Trades adaptedTrades = JustcoinAdapters.adaptPublicTrades(CurrencyPair.BTC_USD, trades);

    assertThat(adaptedTrades.getlastID()).isEqualTo(92726);
View Full Code Here

    // Read in the JSON from the example resources
    final InputStream is = JustcoinTickerTest.class.getResourceAsStream("/marketdata/example-ticker-data.json");

    // Use Jackson to parse it
    final ObjectMapper mapper = new ObjectMapper();
    CollectionType collectionType = mapper.getTypeFactory().constructCollectionType(List.class, JustcoinTicker.class);
    final List<JustcoinTicker> tickers = mapper.readValue(is, collectionType);

    // Verify that the example data was unmarshalled correctly
    assertThat(tickers.size()).isEqualTo(5);
    final JustcoinTicker xrpTicker = tickers.get(4);
View Full Code Here

    // Read in the JSON from the example resources
    InputStream is = CoinbaseMarketDataJsonTest.class.getResourceAsStream("/marketdata/example-currencies-data.json");

    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    CollectionType collectionType = mapper.getTypeFactory().constructCollectionType(List.class, CoinbaseCurrency.class);
    List<CoinbaseCurrency> currencies = mapper.readValue(is, collectionType);

    assertThat(currencies.size()).isEqualTo(161);

    CoinbaseCurrency currency = currencies.get(160);
View Full Code Here

        }
        if (type != null) {
            clazz = exchange.getContext().getClassResolver().resolveMandatoryClass(type);
        }
        if (collectionType != null) {
            CollectionType collType = objectMapper.getTypeFactory().constructCollectionType(collectionType, clazz);
            return this.objectMapper.readValue(stream, collType);
        } else {
            return this.objectMapper.readValue(stream, clazz);
        }
    }
View Full Code Here

    }
  }

  <T> T applyPatch(InputStream source, T target) throws Exception {

    CollectionType listOfOperationsType = mapper.getTypeFactory().constructCollectionType(List.class,
        JsonPatchOperation.class);
    List<JsonPatchOperation> readValue = mapper.readValue(source, listOfOperationsType);

    JsonNode existingAsNode = mapper.readTree(sourceMapper.writeValueAsBytes(target));
    JsonNode patchedNode = existingAsNode;
View Full Code Here

    @Override
    public <T extends Collection<E>, E> T convertValue(Object fromValue,
                                                       Class<T> collectionType,
                                                       Class<E> elementType)
        throws IllegalArgumentException {
      CollectionType collType = mapper.getTypeFactory().constructCollectionType(collectionType, elementType);
      return mapper.convertValue(fromValue, collType);
    }
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.databind.type.CollectionType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.