@Override protected SeekableStreamPartitions<Integer, Long> deserializeSeekableStreamPartitionsFromMetadata( ObjectMapper mapper, Object object ) { return mapper.convertValue(object, mapper.getTypeFactory().constructParametrizedType( SeekableStreamPartitions.class, SeekableStreamPartitions.class, Integer.class, Long.class )); }
@Override protected SeekableStreamPartitions<String, String> deserializeSeekableStreamPartitionsFromMetadata( ObjectMapper mapper, Object object ) { return mapper.convertValue(object, mapper.getTypeFactory().constructParametrizedType( SeekableStreamPartitions.class, SeekableStreamPartitions.class, String.class, String.class )); }
final SeekableStreamPartitions<Integer, Long> restoredNextPartitions = toolbox.getObjectMapper().convertValue( restoredMetadataMap.get(METADATA_NEXT_PARTITIONS), toolbox.getObjectMapper().getTypeFactory().constructParametrizedType( SeekableStreamPartitions.class, SeekableStreamPartitions.class, toolbox.getObjectMapper() .getTypeFactory() .constructParametrizedType( SeekableStreamPartitions.class, SeekableStreamPartitions.class,
public TypedMessageQuery(final HttpRequestIntent httpRequestIntent, final JavaType elementJavaType) { this.httpRequestIntent = httpRequestIntent; final TypeFactory typeFactory = TypeFactory.defaultInstance(); resultJavaType = typeFactory.constructParametrizedType(PagedQueryResult.class, PagedQueryResult.class, elementJavaType); }
private static <T> JavaType resolveJavaType(final JavaType javaType) { final TypeFactory typeFactory = TypeFactory.defaultInstance(); final JavaType resultJavaType = typeFactory.constructParametrizedType(PagedQueryResult.class, PagedQueryResult.class, javaType); return resultJavaType; } }
public TypedMessageQuery(final HttpRequestIntent httpRequestIntent, final JavaType elementJavaType) { this.httpRequestIntent = httpRequestIntent; final TypeFactory typeFactory = TypeFactory.defaultInstance(); resultJavaType = typeFactory.constructParametrizedType(PagedQueryResult.class, PagedQueryResult.class, elementJavaType); }
/** * @deprecated Since 2.5, use {@link #constructParametrizedType} instead. */ @Deprecated public JavaType constructParametricType(Class<?> parametrized, JavaType... parameterTypes) { return constructParametrizedType(parametrized, parametrized, parameterTypes); }
/** * @deprecated Since 2.5, use {@link #constructParametrizedType} instead. */ @Deprecated public JavaType constructParametricType(Class<?> parametrized, JavaType... parameterTypes) { return constructParametrizedType(parametrized, parametrized, parameterTypes); }
public TypedMessageQuery(final HttpRequestIntent httpRequestIntent, final JavaType elementJavaType) { this.httpRequestIntent = httpRequestIntent; final TypeFactory typeFactory = TypeFactory.defaultInstance(); resultJavaType = typeFactory.constructParametrizedType(PagedQueryResult.class, PagedQueryResult.class, elementJavaType); }
/** * @deprecated Since 2.5, use {@link #constructParametrizedType} instead. */ @Deprecated public JavaType constructParametricType(Class<?> parametrized, Class<?>... parameterClasses) { return constructParametrizedType(parametrized, parametrized, parameterClasses); }
private <U> QueryResponse<U> parseResult(String json, Class<U> clazz) throws IOException { ObjectReader reader = jsonObjectMapper .readerFor(jsonObjectMapper.getTypeFactory().constructParametrizedType(QueryResponse.class, QueryResult.class, clazz)); return reader.readValue(json); }
private <U> QueryResponse<U> parseResult(String json, Class<U> clazz) throws IOException { ObjectReader reader = jsonObjectMapper .readerFor(jsonObjectMapper.getTypeFactory().constructParametrizedType(QueryResponse.class, QueryResult.class, clazz)); return reader.readValue(json); }
@SuppressWarnings("unchecked") private List<ConfigKey> fromText(String text) { try { return (List<ConfigKey>) jsonTreeMapper.readValue(text, jsonTreeMapper.getTypeFactory().constructParametrizedType(List.class, List.class, ConfigKey.class)); } catch (IOException ex) { throw Throwables.propagate(ex); } }
@SuppressWarnings("unchecked") @VisibleForTesting List<ArchivedTask> loadTaskArchive(String data) { try { return (List<ArchivedTask>) taskArchiveMapper.readValue(data, taskArchiveMapper.getTypeFactory().constructParametrizedType(List.class, List.class, ArchivedTask.class)); } catch (IOException ex) { throw new RuntimeException("Failed to load task archive", ex); } }
public <T> List<T> toList(String jsonString, Class<T> elementType) { if (StringUtils.isEmpty(jsonString)) { return null; } JavaType javaType = mapper.getTypeFactory().constructParametrizedType(ArrayList.class,ArrayList.class, elementType); return toObject(jsonString, javaType); }
/** * Map with Generic Key and Genric Value, i.e.: Map<String, List<TaggedBucketPoint>> */ public JavaType get(@SuppressWarnings("rawtypes") Class<? extends Map> mapClazz, Class<?> mapClazzKey, Class<?> mapClazzValue, Class<?> mapClazzParametrizedValue) { JavaType mapClazzKeyType = objectMapper.getTypeFactory().constructType(mapClazzKey); JavaType parametrizedClazzType = objectMapper.getTypeFactory().constructParametrizedType(mapClazzValue, mapClazzValue, mapClazzParametrizedValue); return objectMapper.getTypeFactory().constructMapType(mapClazz, mapClazzKeyType, parametrizedClazzType); } }
/** * List with Generic, Generic, i.e.: List<Metric<Double>> */ public JavaType get(@SuppressWarnings("rawtypes") Class<? extends List> collectionClazz, Class<?> clazz, Class<?> parametrizedClazz) { JavaType parametrizedClazzType = objectMapper.getTypeFactory().constructType(parametrizedClazz); JavaType clazzType = objectMapper.getTypeFactory().constructParametrizedType(clazz, clazz, parametrizedClazzType); return objectMapper.getTypeFactory().constructCollectionType(collectionClazz, clazzType); }
public static JavaType getParametizedList(Field field) { ParameterizedType type = (ParameterizedType) field.getGenericType(); JavaType parameterType = Configuration.objectMapper().getTypeFactory().constructType(type.getActualTypeArguments()[0]); return Configuration.objectMapper().getTypeFactory().constructParametrizedType(ArrayList.class, List.class, parameterType); }
/** * Create a new GetContentServiceImpl of the desired parameterized type * @param config The configuration to use * @param documentType The desired document type for service methods. This type must have the correct Jackson annotations * to read HP Haven OnDemand responses */ public GetContentServiceImpl(final HodServiceConfig<?, TokenType.Simple> config, final Class<T> documentType) { getContentBackend = config.getRestAdapter().create(GetContentBackend.class); requester = config.getRequester(); returnType = config.getObjectMapper().getTypeFactory().constructParametrizedType(QueryResults.class, QueryResults.class, documentType); }
/** * Creates a new FindSimilarServiceImpl with the given configuration and return type * @param hodServiceConfig The configuration to use * @param documentType The desired type of the documents returned by the service. This type must have the correct Jackson * annotations to read responses from HP Haven OnDemand */ public FindSimilarServiceImpl(final HodServiceConfig<?, TokenType.Simple> hodServiceConfig, final Class<T> documentType) { findSimilarBackend = hodServiceConfig.getRestAdapter().create(FindSimilarBackend.class); requester = hodServiceConfig.getRequester(); returnType = hodServiceConfig.getObjectMapper().getTypeFactory().constructParametrizedType(QueryResults.class, QueryResults.class , documentType); }