Java Code Examples for com.fasterxml.jackson.databind.type.CollectionType

The following examples show how to use com.fasterxml.jackson.databind.type.CollectionType. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: springdoc-openapi   Author: springdoc   File: CollectionModelContentConverter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Schema<?> resolve(AnnotatedType type, ModelConverterContext context, Iterator<ModelConverter> chain) {
	if (chain.hasNext() && type != null && type.getType() instanceof CollectionType
			&& "_embedded".equalsIgnoreCase(type.getPropertyName())) {
		Schema<?> schema = chain.next().resolve(type, context, chain);
		if (schema instanceof ArraySchema) {
			Class<?> entityType = getEntityType(type);
			String entityClassName = linkRelationProvider.getCollectionResourceRelFor(entityType).value();

			return new ObjectSchema()
					.name("_embedded")
					.addProperties(entityClassName, schema);
		}
	}
	return chain.hasNext() ? chain.next().resolve(type, context, chain) : null;
}
 
Example #2
Source Project: Quicksql   Author: Qihoo360   File: DruidConnectionImpl.java    License: MIT License 6 votes vote down vote up
/** Reads data source names from Druid. */
    Set<String> tableNames() {
        final Map<String, String> requestHeaders =
            ImmutableMap.of("Content-Type", "application/json");
        final String data = null;
        final String url = coordinatorUrl + "/druid/coordinator/v1/metadata/datasources";
//        if (CalcitePrepareImpl.DEBUG) {
//            System.out.println("Druid: table names" + data + "; " + url);
//        }
        try (InputStream in0 = post(url, data, requestHeaders, 10000, 1800000);
            InputStream in = traceResponse(in0)) {
            final ObjectMapper mapper = new ObjectMapper();
            final CollectionType listType =
                mapper.getTypeFactory().constructCollectionType(List.class,
                    String.class);
            final List<String> list = mapper.readValue(in, listType);
            return ImmutableSet.copyOf(list);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
 
Example #3
Source Project: n2o-framework   Author: i-novus-llc   File: TestDataProviderEngineTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testDeleteOnFile() throws IOException {
    TestDataProviderEngine engine = new TestDataProviderEngine();
    engine.setResourceLoader(new DefaultResourceLoader());
    engine.setPathOnDisk(testFolder.getRoot() + "/");

    N2oTestDataProvider provider = new N2oTestDataProvider();
    provider.setFile(testFile.getName());

    //Удаление данных
    provider.setOperation(delete);

    Map<String, Object> inParamsForDelete = new LinkedHashMap<>();
    inParamsForDelete.put("id", 1L);

    engine.invoke(provider, inParamsForDelete);

    //Проверка, что после delete, json файл содержит ожидаемые данные
    ObjectMapper objectMapper = new ObjectMapper();
    TypeFactory typeFactory = objectMapper.getTypeFactory();
    CollectionType collectionType = typeFactory.constructCollectionType(
            List.class, HashMap.class);
    List<Map> result = objectMapper.readValue(testFile, collectionType);

    assertThat(result.size(), is(0));
}
 
Example #4
Source Project: web3sdk   Author: FISCO-BCOS   File: TransactionDecoder.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @param logs
 * @return
 * @throws BaseException
 * @throws IOException
 */
public String decodeEventReturnJson(String logs) throws BaseException, IOException {
    // log json trans to list log
    ObjectMapper mapper = ObjectMapperFactory.getObjectMapper();
    CollectionType listType =
            mapper.getTypeFactory().constructCollectionType(ArrayList.class, Log.class);
    @SuppressWarnings("unchecked")
    List<Log> logList = (List<Log>) mapper.readValue(logs, listType);

    // decode event
    Map<String, List<List<EventResultEntity>>> resultEntityMap =
            decodeEventReturnObject(logList);
    String result = mapper.writeValueAsString(resultEntityMap);

    return result;
}
 
Example #5
Source Project: caravan   Author: ctripcorp   File: MapDeserializerManager.java    License: Apache License 2.0 6 votes vote down vote up
public MapDeserializerManager(MapCustomizationFactory factory) {
  /**
   * The first parameter is just a placeholder, won't be used.
   * So any element type is ok.
   */
  super(
      CollectionType.construct(ArrayList.class, null, null, null, //
          SimpleType.constructUnsafe(Object.class)), //
      null, null, new ValueInstantiator() {
        @SuppressWarnings("rawtypes")
        @Override
        public Object createUsingDefault(DeserializationContext ctxt) throws IOException {
          return new ArrayList();
        }
      });

  this.factory = factory;
}
 
Example #6
Source Project: allure2   Author: allure-framework   File: XmlParserModule.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void setupModule(final SetupContext context) {
    super.setupModule(context);
    context.addBeanDeserializerModifier(new BeanDeserializerModifier() {
        @Override
        public JsonDeserializer<?> modifyCollectionDeserializer(final DeserializationConfig config,
                                                                final CollectionType type,
                                                                final BeanDescription beanDesc,
                                                                final JsonDeserializer<?> deserializer) {
            if (deserializer instanceof CollectionDeserializer) {
                return new ListDeserializer((CollectionDeserializer) deserializer);
            } else {
                return super.modifyCollectionDeserializer(config, type, beanDesc,
                        deserializer);
            }
        }
    });
}
 
Example #7
Source Project: cosmic   Author: MissionCriticalCloud   File: RESTServiceConnectorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCustomDeserializerForCustomLists() throws Exception {
    final CloseableHttpResponse response = mock(CloseableHttpResponse.class);
    when(response.getStatusLine()).thenReturn(HTTP_200_STATUS_LINE);
    when(response.getEntity()).thenReturn(new StringEntity("{results: [{field : \"SomeValue\"}], results_count: 1}"));
    final CloseableHttpClient httpClient = mock(CloseableHttpClient.class);
    when(httpClient.execute(any(HttpHost.class), any(HttpRequest.class), any(HttpClientContext.class))).thenReturn(response);
    final RestClient restClient = new BasicRestClient(httpClient, HttpClientContext.create(), "localhost");
    final Class<? extends CollectionType> clazzListOfTestPojo = new ObjectMapper().getTypeFactory().constructCollectionType(List.class, TestPojo.class).getClass();
    final RESTServiceConnector connector = new RESTServiceConnector.Builder()
            .client(restClient)
            .classToDeserializerEntry(clazzListOfTestPojo, new CustomListDeserializer<TestPojoDeserializer>())
            .build();

    connector.executeRetrieveObject(TestPojo.class, "/somepath");
}
 
Example #8
Source Project: peer-os   Author: subutai-io   File: RestServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
private Map<String, ContainerQuota> getChangedContainers( final String quotaContainers ) throws java.io.IOException
{
    Map<String, ContainerQuota> changedContainersFiltered = new HashMap<>();
    TypeFactory typeFactory = mapper.getTypeFactory();
    CollectionType arrayType = typeFactory.constructCollectionType( ArrayList.class, ChangedContainerDto.class );
    List<ChangedContainerDto> changedContainers = mapper.readValue( quotaContainers, arrayType );
    for ( ChangedContainerDto cont : changedContainers )
    {
        ContainerQuotaDto containerQuotaDto = cont.getQuota();
        ContainerSize containerSize = containerQuotaDto.getContainerSize();
        ContainerQuota defaultQuota = ContainerSize.getDefaultContainerQuota( containerSize );
        if ( containerSize == ContainerSize.CUSTOM )
        {
            defaultQuota = containerQuotaDto.getContainerQuota();
        }

        changedContainersFiltered.put( cont.getHostId(), defaultQuota );
    }
    return changedContainersFiltered;
}
 
Example #9
Source Project: calcite   Author: apache   File: DruidConnectionImpl.java    License: Apache License 2.0 6 votes vote down vote up
/** Reads data source names from Druid. */
Set<String> tableNames() {
  final Map<String, String> requestHeaders =
      ImmutableMap.of("Content-Type", "application/json");
  final String data = null;
  final String url = coordinatorUrl + "/druid/coordinator/v1/metadata/datasources";
  if (CalciteSystemProperty.DEBUG.value()) {
    System.out.println("Druid: table names" + data + "; " + url);
  }
  try (InputStream in0 = post(url, data, requestHeaders, 10000, 1800000);
       InputStream in = traceResponse(in0)) {
    final ObjectMapper mapper = new ObjectMapper();
    final CollectionType listType =
        mapper.getTypeFactory().constructCollectionType(List.class,
            String.class);
    final List<String> list = mapper.readValue(in, listType);
    return ImmutableSet.copyOf(list);
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
Example #10
Source Project: docker-java   Author: docker-java   File: ContainerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void serderJson1() throws IOException {
    final CollectionType type = JSONTestHelper.getMapper().getTypeFactory().constructCollectionType(List.class, Container.class);

    final List<Container> containers = testRoundTrip(RemoteApiVersion.VERSION_1_22,
            "containers/json/filter1.json",
            type
    );

    assertThat(containers.size(), equalTo(1));

    final Container container = containers.get(0);

    assertThat(container.getImageId(),
            equalTo("sha256:0cb40641836c461bc97c793971d84d758371ed682042457523e4ae701efe7ec9"));
    assertThat(container.getSizeRootFs(), equalTo(1113554L));

    final ContainerHostConfig hostConfig = container.getHostConfig();
    assertThat(hostConfig, notNullValue());
    assertThat(hostConfig.getNetworkMode(), equalTo("default"));
}
 
Example #11
Source Project: cloudstack   Author: apache   File: RESTServiceConnectorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCustomDeserializerForCustomLists() throws Exception {
    final CloseableHttpResponse response = mock(CloseableHttpResponse.class);
    when(response.getStatusLine()).thenReturn(HTTP_200_STATUS_LINE);
    when(response.getEntity()).thenReturn(new StringEntity("{results: [{field : \"SomeValue\"}], results_count: 1}"));
    final CloseableHttpClient httpClient = mock(CloseableHttpClient.class);
    when(httpClient.execute(any(HttpHost.class), any(HttpRequest.class), any(HttpClientContext.class))).thenReturn(response);
    final RestClient restClient = new BasicRestClient(httpClient, HttpClientContext.create(), "localhost");
    final Class<? extends CollectionType> clazzListOfTestPojo = new ObjectMapper().getTypeFactory().constructCollectionType(List.class, TestPojo.class).getClass();
    final RESTServiceConnector connector = new RESTServiceConnector.Builder()
        .client(restClient)
        .classToDeserializerEntry(clazzListOfTestPojo, new CustomListDeserializer<TestPojoDeserializer>())
        .build();

    connector.executeRetrieveObject(TestPojo.class, "/somepath");
}
 
Example #12
Source Project: mollyim-android   Author: mollyim   File: RecentEmojiPageModel.java    License: GNU General Public License v3.0 5 votes vote down vote up
private LinkedHashSet<String> getPersistedCache() {
  String serialized = prefs.getString(preferenceName, "[]");
  try {
    CollectionType collectionType = TypeFactory.defaultInstance()
                                               .constructCollectionType(LinkedHashSet.class, String.class);
    return JsonUtils.getMapper().readValue(serialized, collectionType);
  } catch (IOException e) {
    Log.w(TAG, e);
    return new LinkedHashSet<>();
  }
}
 
Example #13
Source Project: springdoc-openapi   Author: springdoc   File: CollectionModelContentConverter.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Gets entity type.
 *
 * @param type the type 
 * @return the entity type
 */
private Class<?> getEntityType(AnnotatedType type) {
	Class<?> containerEntityType = ((CollectionType) (type.getType())).getContentType().getRawClass();
	if (containerEntityType.isAssignableFrom(EntityModel.class)) {
		TypeBindings typeBindings = ((CollectionType) type.getType()).getContentType().getBindings() ;
		if (!CollectionUtils.isEmpty(typeBindings.getTypeParameters()))
			return typeBindings.getBoundType(0).getRawClass();
	}
	return containerEntityType;
}
 
Example #14
Source Project: kogito-runtimes   Author: kiegroup   File: KogitoModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public JsonDeserializer<?> createContextual( DeserializationContext ctxt, BeanProperty property) throws JsonMappingException {
    CollectionType collectionType = ctxt.getTypeFactory().constructCollectionType(List.class, property.getType().containedType(0));
    DataStreamDeserializer deserializer = new DataStreamDeserializer();
    deserializer.collectionType = collectionType;
    return deserializer;
}
 
Example #15
Source Project: kogito-runtimes   Author: kiegroup   File: KogitoModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException {
    CollectionType collectionType = ctxt.getTypeFactory().constructCollectionType(List.class, property.getType().containedType(0));
    DataStoreDeserializer deserializer = new DataStoreDeserializer();
    deserializer.collectionType = collectionType;
    return deserializer;
}
 
Example #16
Source Project: kogito-runtimes   Author: kiegroup   File: KogitoQuarkusObjectMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public JsonDeserializer<?> createContextual( DeserializationContext ctxt, BeanProperty property) throws JsonMappingException {
    CollectionType collectionType = ctxt.getTypeFactory().constructCollectionType(List.class, property.getType().containedType(0));
    DataStreamDeserializer deserializer = new DataStreamDeserializer();
    deserializer.collectionType = collectionType;
    return deserializer;
}
 
Example #17
Source Project: kogito-runtimes   Author: kiegroup   File: KogitoQuarkusObjectMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException {
    CollectionType collectionType = ctxt.getTypeFactory().constructCollectionType(List.class, property.getType().containedType(0));
    DataStoreDeserializer deserializer = new DataStoreDeserializer();
    deserializer.collectionType = collectionType;
    return deserializer;
}
 
Example #18
Source Project: kogito-runtimes   Author: kiegroup   File: KogitoSpringObjectMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public JsonDeserializer<?> createContextual( DeserializationContext ctxt, BeanProperty property) throws JsonMappingException {
    CollectionType collectionType = ctxt.getTypeFactory().constructCollectionType(List.class, property.getType().containedType(0));
    DataStreamDeserializer deserializer = new DataStreamDeserializer();
    deserializer.collectionType = collectionType;
    return deserializer;
}
 
Example #19
Source Project: kogito-runtimes   Author: kiegroup   File: KogitoSpringObjectMapper.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException {
    CollectionType collectionType = ctxt.getTypeFactory().constructCollectionType(List.class, property.getType().containedType(0));
    DataStoreDeserializer deserializer = new DataStoreDeserializer();
    deserializer.collectionType = collectionType;
    return deserializer;
}
 
Example #20
Source Project: docker-swarm-plugin   Author: jenkinsci   File: Jackson.java    License: MIT License 5 votes vote down vote up
private static <T> T fromJSONArray(ObjectMapper mapper, String json, Class<T> expectedType) {
  try {
    CollectionType arrayType = mapper.getTypeFactory().constructCollectionType(List.class, expectedType);
    return mapper.readerFor(arrayType).readValue(json);
  } catch (IOException e) {
    throw new IllegalArgumentException("Cannot unmarshal JSON as " + expectedType.getSimpleName(), e);
  }
}
 
Example #21
Source Project: n2o-framework   Author: i-novus-llc   File: TestDataProviderEngine.java    License: Apache License 2.0 5 votes vote down vote up
private List<DataSet> loadJson(InputStream is, PrimaryKeyType primaryKeyType, String primaryKeyFieldId) throws IOException {
    TypeFactory typeFactory = objectMapper.getTypeFactory();
    CollectionType collectionType = typeFactory.constructCollectionType(
            List.class, DataSet.class);
    List<DataSet> dataList = objectMapper.readValue(is, collectionType);
    for (DataSet data : dataList) {
        if (data.containsKey(primaryKeyFieldId) && integer.equals(primaryKeyType))
            data.put(primaryKeyFieldId, ((Number) data.get(primaryKeyFieldId)).longValue());
    }
    return dataList;
}
 
Example #22
Source Project: n2o-framework   Author: i-novus-llc   File: TestDataProviderEngineTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateOnFile() throws IOException {
    TestDataProviderEngine engine = new TestDataProviderEngine();
    engine.setResourceLoader(new DefaultResourceLoader());
    engine.setPathOnDisk(testFolder.getRoot() + "/");

    N2oTestDataProvider provider = new N2oTestDataProvider();
    provider.setFile(testFile.getName());

    //Добавление новых данных
    provider.setOperation(create);

    Map<String, Object> inParamsForCreate = new LinkedHashMap<>();
    inParamsForCreate.put("id", 9L);
    inParamsForCreate.put("name", "test9");
    inParamsForCreate.put("type", "9");

    engine.invoke(provider, inParamsForCreate);

    //Проверка, что после create, json файл содержит ожидаемые данные
    ObjectMapper objectMapper = new ObjectMapper();
    TypeFactory typeFactory = objectMapper.getTypeFactory();
    CollectionType collectionType = typeFactory.constructCollectionType(
            List.class, HashMap.class);
    List<Map> result = objectMapper.readValue(testFile, collectionType);

    assertThat(result.size(), is(2));
    assertThat(result.get(0).get("id"), is(9));
    assertThat(result.get(0).get("name"), is("test9"));
    assertThat(result.get(0).get("type"), is("9"));
    assertThat(result.get(1).get("id"), is(1));
    assertThat(result.get(1).get("name"), is("test1"));
    assertThat(result.get(1).get("type"), is("1"));
}
 
Example #23
Source Project: n2o-framework   Author: i-novus-llc   File: TestDataProviderEngineTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testUpdateOnFile() throws IOException {
    TestDataProviderEngine engine = new TestDataProviderEngine();
    engine.setResourceLoader(new DefaultResourceLoader());
    engine.setPathOnDisk(testFolder.getRoot() + "/");

    N2oTestDataProvider provider = new N2oTestDataProvider();
    provider.setFile(testFile.getName());

    //Обновление данных
    provider.setOperation(update);

    Map<String, Object> inParamsForUpdate = new LinkedHashMap<>();
    inParamsForUpdate.put("id", 1L);
    inParamsForUpdate.put("name", "test9");
    inParamsForUpdate.put("type", "9");

    engine.invoke(provider, inParamsForUpdate);

    //Проверка, что после update, json файл содержит ожидаемые данные
    ObjectMapper objectMapper = new ObjectMapper();
    TypeFactory typeFactory = objectMapper.getTypeFactory();
    CollectionType collectionType = typeFactory.constructCollectionType(
            List.class, HashMap.class);
    List<Map> result = objectMapper.readValue(testFile, collectionType);

    assertThat(result.size(), is(1));
    assertThat(result.get(0).get("id"), is(1));
    assertThat(result.get(0).get("name"), is("test9"));
    assertThat(result.get(0).get("type"), is("9"));
}
 
Example #24
Source Project: n2o-framework   Author: i-novus-llc   File: TestDataProviderEngineTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testUpdateFieldOnFile() throws IOException {
    TestDataProviderEngine engine = new TestDataProviderEngine();
    engine.setResourceLoader(new DefaultResourceLoader());
    engine.setPathOnDisk(testFolder.getRoot() + "/");

    N2oTestDataProvider provider = new N2oTestDataProvider();
    provider.setFile(testFile.getName());

    //Обновление данных поля
    provider.setOperation(updateField);

    Map<String, Object> inParamsForUpdate = new LinkedHashMap<>();
    inParamsForUpdate.put("id", 1L);
    inParamsForUpdate.put("key", "name");
    inParamsForUpdate.put("value", "newName");

    engine.invoke(provider, inParamsForUpdate);

    //Проверка, что после updateField, json файл содержит ожидаемые данные
    ObjectMapper objectMapper = new ObjectMapper();
    TypeFactory typeFactory = objectMapper.getTypeFactory();
    CollectionType collectionType = typeFactory.constructCollectionType(
            List.class, HashMap.class);
    List<Map> result = objectMapper.readValue(testFile, collectionType);

    assertThat(result.size(), is(1));
    assertThat(result.get(0).get("id"), is(1));
    assertThat(result.get(0).get("name"), is("newName"));
    assertThat(result.get(0).get("type"), is("1"));
}
 
Example #25
Source Project: n2o-framework   Author: i-novus-llc   File: TestDataProviderEngineTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateOnEmptyFile() throws IOException {
    TestDataProviderEngine engine = new TestDataProviderEngine();
    engine.setResourceLoader(new DefaultResourceLoader());
    engine.setPathOnDisk(testFolder.getRoot() + "/");

    N2oTestDataProvider provider = new N2oTestDataProvider();
    provider.setFile(emptyFile.getName());

    //Добавление новых данных в пустой файл
    provider.setOperation(create);

    Map<String, Object> inParamsForCreate = new LinkedHashMap<>();
    inParamsForCreate.put("name", "test10");
    inParamsForCreate.put("type", "10");

    engine.invoke(provider, inParamsForCreate);

    //Проверка, что после create, json файл содержит ожидаемые данные
    ObjectMapper objectMapper = new ObjectMapper();
    TypeFactory typeFactory = objectMapper.getTypeFactory();
    CollectionType collectionType = typeFactory.constructCollectionType(
            List.class, HashMap.class);
    List<Map> result = objectMapper.readValue(emptyFile, collectionType);

    assertThat(result.size(), is(1));
    assertThat(result.get(0).get("id"), is(1));
    assertThat(result.get(0).get("name"), is("test10"));
    assertThat(result.get(0).get("type"), is("10"));
}
 
Example #26
Source Project: Learning-Path-Spring-5-End-to-End-Programming   Author: PacktPublishing   File: BookingService.java    License: MIT License 5 votes vote down vote up
public Mono<Set<Booking>> bookingOfFlight(String bookingId) {
  return discoveryService.serviceAddressFor(this.bookingService).next().flatMap(
      address -> this.webClient.mutate()
          .baseUrl(address + "/" + this.bookingServiceApiPath + "/" + bookingId).build().get()
          .exchange()
          .flatMap(clientResponse ->
              {
                final CollectionType type = mapper.getTypeFactory().
                    constructCollectionType(Set.class, Booking.class);
                return clientResponse.bodyToMono(ParameterizedTypeReference.forType(type));
              }
          ));
}
 
Example #27
Source Project: Learning-Path-Spring-5-End-to-End-Programming   Author: PacktPublishing   File: BookingService.java    License: MIT License 5 votes vote down vote up
public Mono<Set<Booking>> bookingOfFlight(String bookingId) {
  return discoveryService.serviceAddressFor(this.bookingService).next().flatMap(
      address -> this.webClient.mutate()
          .baseUrl(address + "/" + this.bookingServiceApiPath + "/" + bookingId).build().get()
          .exchange()
          .flatMap(clientResponse ->
              {
                final CollectionType type = mapper.getTypeFactory().
                    constructCollectionType(Set.class, Booking.class);
                return clientResponse.bodyToMono(ParameterizedTypeReference.forType(type));
              }
          ));
}
 
Example #28
Source Project: Spring-5.0-By-Example   Author: PacktPublishing   File: BookingService.java    License: MIT License 5 votes vote down vote up
public Mono<Set<Booking>> bookingOfFlight(String bookingId) {
  return discoveryService.serviceAddressFor(this.bookingService).next().flatMap(
      address -> this.webClient.mutate()
          .baseUrl(address + "/" + this.bookingServiceApiPath + "/" + bookingId).build().get()
          .exchange()
          .flatMap(clientResponse ->
              {
                final CollectionType type = mapper.getTypeFactory().
                    constructCollectionType(Set.class, Booking.class);
                return clientResponse.bodyToMono(ParameterizedTypeReference.forType(type));
              }
          ));
}
 
Example #29
Source Project: caravan   Author: ctripcorp   File: MapDeserializer.java    License: Apache License 2.0 5 votes vote down vote up
public MapDeserializer(JavaType pairType) {
  super(
      CollectionType.construct(ArrayList.class, null, null, null, pairType), //
      null, null, new ValueInstantiator() {
        @Override
        public Object createUsingDefault(DeserializationContext ctxt) throws IOException {
          return new ArrayList();
        }
      });
}
 
Example #30
Source Project: titus-control-plane   Author: Netflix   File: CompositeDeserializers.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public JsonDeserializer<?> findCollectionDeserializer(CollectionType type, DeserializationConfig config, BeanDescription beanDesc,
                                                      TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer)
        throws JsonMappingException {
    for (Deserializers deserializers : deserializersList) {
        JsonDeserializer<?> deserializer = deserializers.findCollectionDeserializer(type, config, beanDesc, elementTypeDeserializer, elementDeserializer);
        if (deserializer != null) {
            return deserializer;
        }
    }
    return null;
}