com.fasterxml.jackson.databind.type.ArrayType Java Examples
The following examples show how to use
com.fasterxml.jackson.databind.type.ArrayType.
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 File: WebFluxSupportConverter.java From springdoc-openapi with Apache License 2.0 | 6 votes |
@Override public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterator<ModelConverter> chain) { JavaType javaType = Json.mapper().constructType(type.getType()); if (javaType != null) { Class<?> cls = javaType.getRawClass(); if (isFluxTypeWrapper(cls)) { JavaType innerType = javaType.getBindings().getBoundType(0); if (innerType == null) return new StringSchema(); else if (innerType.getBindings() != null && isResponseTypeWrapper(innerType.getRawClass())) { type = new AnnotatedType(innerType).jsonViewAnnotation(type.getJsonViewAnnotation()).resolveAsRef(true); return this.resolve(type, context, chain); } else { ArrayType arrayType = ArrayType.construct(innerType, null); type = new AnnotatedType(arrayType).jsonViewAnnotation(type.getJsonViewAnnotation()).resolveAsRef(true); } } } return (chain.hasNext()) ? chain.next().resolve(type, context, chain) : null; }
Example #2
Source File: JsonUtils.java From nuls-v2 with MIT License | 5 votes |
public static <T> T toArray(String value, Class<?> elementType) { ArrayType arrayType = TypeFactory.defaultInstance().constructArrayType(elementType); try { return OBJECT_MAPPER.readValue(value, arrayType); } catch (IOException e) { throw new RuntimeException(e); } }
Example #3
Source File: JsonUtils.java From nuls with MIT License | 5 votes |
public static <T> T toArray(String value, Class<?> elementType) { ArrayType arrayType = TypeFactory.defaultInstance().constructArrayType(elementType); try { return OBJECT_MAPPER.readValue(value, arrayType); } catch (IOException e) { throw new RuntimeException(e); } }
Example #4
Source File: CustomSimpleSerializers.java From caravan with Apache License 2.0 | 5 votes |
@SuppressWarnings("rawtypes") @Override public JsonSerializer<?> findArraySerializer(SerializationConfig config, ArrayType type, BeanDescription beanDesc, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) { Class<?> contentClass = type.getContentType().getRawClass(); TypeCustomizationFactory factory = provider.factoryForArrayOf(contentClass); if (factory != null) { final JsonSerializer ser = factory.createSerializer(); return new JsonSerializer() { @SuppressWarnings("unchecked") @Override public void serialize(Object o, JsonGenerator gen, SerializerProvider serializerProvider) throws IOException { gen.writeStartArray(); gen.setCurrentValue(o); int length = Array.getLength(o); for (int i = 0; i < length; i++) { Object arrayElement = Array.get(o, i); ser.serialize(arrayElement, gen, serializerProvider); } gen.writeEndArray(); } }; } return super.findArraySerializer(config, type, beanDesc, elementTypeSerializer, elementValueSerializer); }
Example #5
Source File: CompositeDeserializers.java From titus-control-plane with Apache License 2.0 | 5 votes |
@Override public JsonDeserializer<?> findArrayDeserializer(ArrayType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException { for (Deserializers deserializers : deserializersList) { JsonDeserializer<?> deserializer = deserializers.findArrayDeserializer(type, config, beanDesc, elementTypeDeserializer, elementDeserializer); if (deserializer != null) { return deserializer; } } return null; }
Example #6
Source File: SimpleSerializers.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public JsonSerializer<?> findArraySerializer(SerializationConfig config, ArrayType type, BeanDescription beanDesc, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) { return findSerializer(config, type, beanDesc); }
Example #7
Source File: CustomSimpleDeserializers.java From caravan with Apache License 2.0 | 4 votes |
@SuppressWarnings("rawtypes") @Override public JsonDeserializer<?> findArrayDeserializer(ArrayType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException { final Class<?> contentClass = type.getContentType().getRawClass(); TypeCustomizationFactory factory = provider.factoryForArrayOf(contentClass); if (factory != null) { final JsonDeserializer des = factory.createDeserializer(); return new JsonDeserializer() { @SuppressWarnings("unchecked") @Override public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { List result = new LinkedList(); try { while (p.nextToken() != JsonToken.END_ARRAY) { Object value = des.deserialize(p, ctxt); result.add(value); } } catch (Exception e) { throw new RuntimeException("Unexpected deserialize protobuf error", e); } Object arrayResult = Array.newInstance(contentClass, result.size()); int i = 0; for (Object o : result) { Array.set(arrayResult, i, o); i++; } return arrayResult; } }; } return super.findArrayDeserializer(type, config, beanDesc, elementTypeDeserializer, elementDeserializer); }
Example #8
Source File: AssignableFromDeserializers.java From titus-control-plane with Apache License 2.0 | 4 votes |
@Override public JsonDeserializer<?> findArrayDeserializer(ArrayType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException { return getDeserializer(type.getRawClass()); }
Example #9
Source File: ConvertingDeserializers.java From graphql-spqr with Apache License 2.0 | 4 votes |
@Override public JsonDeserializer<?> findArrayDeserializer(ArrayType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) { return forJavaType(type); }
Example #10
Source File: ObjectMapperUtil.java From endpoints-java with Apache License 2.0 | 4 votes |
@Override public JsonSerializer<?> modifyArraySerializer(SerializationConfig config, ArrayType valueType, BeanDescription beanDesc, JsonSerializer<?> serializer) { return new DeepEmptyCheckingSerializer<>(serializer); }
Example #11
Source File: BeanDeserializerModifier.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Method called by {@link DeserializerFactory} after it has constructed the * standard deserializer for given * {@link ArrayType} * to make it possible to either replace or augment this deserializer with * additional functionality. * * @param config Configuration in use * @param valueType Type of the value deserializer is used for. * @param beanDesc Description f * @param deserializer Default deserializer that would be used. * * @return Deserializer to use; either <code>deserializer</code> that was passed * in, or an instance method constructed. * * @since 2.2 */ public JsonDeserializer<?> modifyArrayDeserializer(DeserializationConfig config, ArrayType valueType, BeanDescription beanDesc, JsonDeserializer<?> deserializer) { return deserializer; }