@Deprecated public static JavaType collectionType(Class<? extends Collection> collectionType, JavaType elementType) { return instance.constructCollectionType(collectionType, elementType); }
@Deprecated public static JavaType collectionType(Class<? extends Collection> collectionType, Class<?> elementType) { return instance.constructCollectionType(collectionType, instance.constructType(elementType)); }
throw new IllegalArgumentException("Need exactly 1 parameter type for Collection types ("+parametrized.getName()+")"); resultType = constructCollectionType((Class<Collection<?>>)parametrized, parameterTypes[0]); } else { resultType = constructSimpleType(parametrized, parameterTypes);
Class<?> enumClass = ClassUtil.findEnumType((EnumSet<?>) value); str = TypeFactory.defaultInstance().constructCollectionType(EnumSet.class, enumClass).toCanonical(); } else if (value instanceof EnumMap<?,?>) { Class<?> enumClass = ClassUtil.findEnumType((EnumMap<?,?>) value);
@Deprecated public static JavaType collectionType(Class<? extends Collection> collectionType, JavaType elementType) { return instance.constructCollectionType(collectionType, elementType); }
@Deprecated public static JavaType collectionType(Class<? extends Collection> collectionType, Class<?> elementType) { return instance.constructCollectionType(collectionType, instance.constructType(elementType)); }
protected JSONMetricsContainer createContainer(String body, String tenantId) throws JsonParseException, JsonMappingException, IOException { //mapping List<JSONMetric> jsonMetrics = mapper.readValue( body, typeFactory.constructCollectionType(List.class, JSONMetric.class) ); //validation List<ErrorResponse.ErrorData> validationErrors = new ArrayList<ErrorResponse.ErrorData>(); List<JSONMetric> validJsonMetrics = new ArrayList<JSONMetric>(); for (JSONMetric metric: jsonMetrics) { Set<ConstraintViolation<JSONMetric>> constraintViolations = validator.validate(metric); if (constraintViolations.size() == 0) { validJsonMetrics.add(metric); } else { for (ConstraintViolation<JSONMetric> constraintViolation : constraintViolations) { validationErrors.add(new ErrorResponse.ErrorData(tenantId, metric.getMetricName(), constraintViolation.getPropertyPath().toString(), constraintViolation.getMessage(), metric.getCollectionTime())); } } } return new JSONMetricsContainer(tenantId, validJsonMetrics, validationErrors); }
mapper.readValue( body, typeFactory.constructCollectionType(List.class, JSONMetricScoped.class) );
throw new IllegalArgumentException("Need exactly 1 parameter type for Collection types ("+parametrized.getName()+")"); resultType = constructCollectionType((Class<Collection<?>>)parametrized, parameterTypes[0]); } else { resultType = constructSimpleType(parametrized, parameterTypes);
private JSONMetricsContainer getScopedContainer( String name, String jsonBody ) throws java.io.IOException { List<JSONMetric> jsonMetrics = mapper.readValue( jsonBody, typeFactory.constructCollectionType(List.class, JSONMetricScoped.class) ); return new JSONMetricsContainer( name, jsonMetrics, new ArrayList<ErrorResponse.ErrorData>()); } private JSONMetricsContainer getContainer( String tenantId, String jsonBody ) throws java.io.IOException {
Class<?> enumClass = ClassUtil.findEnumType((EnumSet<?>) value); str = TypeFactory.defaultInstance().constructCollectionType(EnumSet.class, enumClass).toCanonical(); } else if (value instanceof EnumMap<?,?>) { Class<?> enumClass = ClassUtil.findEnumType((EnumMap<?,?>) value);
.constructCollectionType(List.class, MongoPrimeUser.class));
public static List<String> jsonToList(String jsonString) throws IOException { ObjectMapper mapper = new ObjectMapper(); CollectionType type = mapper.getTypeFactory().constructCollectionType(List.class, String.class); List<String> data = mapper.readValue(jsonString, type); return data; } }
/** * Deserialize Notification Definition and convert all config to Key Value Pairs * @param notificationDef * @return * @throws Exception */ public static List<Map<String,String>> deserializeNotificationConfig( String notificationDef ) throws Exception { CollectionType mapCollectionType = OBJECT_MAPPER.getTypeFactory().constructCollectionType(List.class, Map.class); return OBJECT_MAPPER.readValue(notificationDef, mapCollectionType); }
@Override public List<ObjectField> getIdeaObjectFields(ApplicationInstance instance) { String objectJson = RESPONSE_GET_IDEA_OBJECTS_FIELDS; LOGGER.info(objectJson); ObjectMapper mapper = new ObjectMapper(); try { return mapper.readValue(objectJson, TypeFactory.defaultInstance().constructCollectionType(List.class, ObjectField.class)); } catch (IOException e) { throw new RuntimeException(e); } }
@Deprecated @SuppressWarnings("unchecked") public static JavaType collectionType(Class<? extends Collection> collectionType, Class<?> elementType) { return instance.constructCollectionType(collectionType, instance.constructType(elementType)); }
@Deprecated public static JavaType collectionType(Class<? extends Collection> collectionType, Class<?> elementType) { return instance.constructCollectionType(collectionType, instance.constructType(elementType)); }
@SuppressWarnings("unchecked") protected <T> List<T> deserializeDataList(JsonNode jsonNode, final Class<T> elementType) { try { CollectionType listType = TypeFactory.defaultInstance() .constructCollectionType(List.class, elementType); return (List<T>) objectMapper.readValue(jsonNode, listType); } catch (IOException e) { throw new UncategorizedApiException( "Error deserializing data from Weibo: " + e.getMessage(), e); } }
@Override public <T> List<T> readList(InputStream stream, Class<T> clazz) throws CoreRtException { TypeFactory typeFactory = TypeFactory.defaultInstance(); CollectionType collectionType = typeFactory.constructCollectionType(ArrayList.class, clazz); try { return OBJECT_MAPPER.readValue(stream, collectionType); } catch (IOException e) { throw new CoreRtException(e); } }
public <T extends Serializable> List<T> deserializeUnformattedList(String source, Class<T> contentType) { try { CollectionType type = unformattedMapper.getTypeFactory().constructCollectionType(List.class, contentType); return unformattedMapper.readValue(source, type); } catch (IOException e) { throw new SerializationException(e); } }