com.fasterxml.jackson.databind.BeanDescription Java Examples

The following examples show how to use com.fasterxml.jackson.databind.BeanDescription. 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: vividus   Author: vividus-framework   File: ObjectMapperFactory.java    License: Apache License 2.0 6 votes vote down vote up
public static ObjectMapper createWithCaseInsensitiveEnumDeserializer()
{
    SimpleModule module = new SimpleModule();
    module.setDeserializerModifier(new BeanDeserializerModifier()
    {
        @Override
        public JsonDeserializer<Enum<?>> modifyEnumDeserializer(DeserializationConfig config, final JavaType type,
                BeanDescription beanDescription, final JsonDeserializer<?> deserializer)
        {
            return new JsonDeserializer<>()
            {
                @SuppressWarnings({ "unchecked", "rawtypes" })
                @Override
                public Enum<?> deserialize(JsonParser parser, DeserializationContext context) throws IOException
                {
                    return Enum.valueOf((Class<? extends Enum>) type.getRawClass(),
                            parser.getValueAsString().toUpperCase());
                }
            };
        }
    });
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(module);
    return objectMapper;
}
 
Example #2
Source Project: jsonschema-generator   Author: victools   File: JacksonModule.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Determine whether a given field should be ignored, according to various jackson annotations for that purpose,
 * <br>
 * e.g. {@code JsonBackReference}, {@code JsonIgnore}, {@code JsonIgnoreType}, {@code JsonIgnoreProperties}
 *
 * @param field field to check
 * @return whether field should be excluded
 */
protected boolean shouldIgnoreField(FieldScope field) {
    if (field.getAnnotationConsideringFieldAndGetter(JsonBackReference.class) != null) {
        return true;
    }
    // instead of re-creating the various ways a property may be included/excluded in jackson: just use its built-in introspection
    BeanDescription beanDescription = this.getBeanDescriptionForClass(field.getDeclaringType());
    // some kinds of field ignorals are only available via an annotation introspector
    Set<String> ignoredProperties = this.objectMapper.getSerializationConfig().getAnnotationIntrospector()
            .findPropertyIgnorals(beanDescription.getClassInfo()).getIgnored();
    String fieldName = field.getName();
    if (ignoredProperties.contains(fieldName)) {
        return true;
    }
    // other kinds of field ignorals are handled implicitly, i.e. are only available by way of being absent
    return beanDescription.findProperties().stream()
            .noneMatch(propertyDefinition -> fieldName.equals(propertyDefinition.getInternalName()));
}
 
Example #3
Source Project: flink   Author: flink-tpc-ds   File: BeanDeserializerModifierForIgnorables.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public List<BeanPropertyDefinition> updateProperties(
	DeserializationConfig config, BeanDescription beanDesc,
	List<BeanPropertyDefinition> propDefs) {
	if (!type.equals(beanDesc.getBeanClass())) {
		return propDefs;
	}

	List<BeanPropertyDefinition> newPropDefs = new ArrayList<>();
	for (BeanPropertyDefinition propDef : propDefs) {
		if (!ignorables.contains(propDef.getName())) {
			newPropDefs.add(propDef);
		}
	}
	return newPropDefs;
}
 
Example #4
Source Project: client-sdk-java   Author: PlatONnetwork   File: ObjectMapperFactory.java    License: Apache License 2.0 6 votes vote down vote up
private static ObjectMapper configureObjectMapper(
        ObjectMapper objectMapper, boolean shouldIncludeRawResponses) {
    if (shouldIncludeRawResponses) {
        SimpleModule module = new SimpleModule();
        module.setDeserializerModifier(new BeanDeserializerModifier() {
            @Override
            public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config,
                                                          BeanDescription beanDesc,
                                                          JsonDeserializer<?> deserializer) {
                if (Response.class.isAssignableFrom(beanDesc.getBeanClass())) {
                    return new RawResponseDeserializer(deserializer);
                }

                return deserializer;
            }
        });

        objectMapper.registerModule(module);
    }

    objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    return objectMapper;
}
 
Example #5
Source Project: etherscan-explorer   Author: bing-chou   File: ObjectMapperFactory.java    License: GNU General Public License v3.0 6 votes vote down vote up
private static ObjectMapper configureObjectMapper(
        ObjectMapper objectMapper, boolean shouldIncludeRawResponses) {
    if (shouldIncludeRawResponses) {
        SimpleModule module = new SimpleModule();
        module.setDeserializerModifier(new BeanDeserializerModifier() {
            @Override
            public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config,
                                                          BeanDescription beanDesc,
                                                          JsonDeserializer<?> deserializer) {
                if (Response.class.isAssignableFrom(beanDesc.getBeanClass())) {
                    return new RawResponseDeserializer(deserializer);
                }

                return deserializer;
            }
        });

        objectMapper.registerModule(module);
    }

    objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    return objectMapper;
}
 
Example #6
Source Project: Rosetta   Author: HubSpot   File: StoredAsJsonBeanSerializerModifier.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public List<BeanPropertyWriter> changeProperties(SerializationConfig config, BeanDescription beanDesc, List<BeanPropertyWriter> beanProperties) {
  for (BeanPropertyWriter beanProperty : beanProperties) {
    StoredAsJson storedAsJson = beanProperty.getAnnotation(StoredAsJson.class);
    if (storedAsJson != null && !StoredAsJson.NULL.equals(storedAsJson.empty())) {
      final JsonSerializer<Object> nullSerializer;
      if (storedAsJson.binary()) {
        nullSerializer = new ConstantBinarySerializer(storedAsJson.empty());
      } else {
        nullSerializer = new ConstantSerializer(storedAsJson.empty());
      }

      beanProperty.assignNullSerializer(nullSerializer);
    }
  }

  return super.changeProperties(config, beanDesc, beanProperties);
}
 
Example #7
Source Project: bowman   Author: BlackPepperSoftware   File: JacksonClientModule.java    License: Apache License 2.0 6 votes vote down vote up
public JacksonClientModule() {
	setSerializerModifier(new BeanSerializerModifier() {

		@Override
		public List<BeanPropertyWriter> changeProperties(SerializationConfig config, BeanDescription beanDesc,
				List<BeanPropertyWriter> beanProperties) {
			
			for (BeanPropertyWriter writer : beanProperties) {
				if (writer.getAnnotation(LinkedResource.class) != null) {
					writer.assignSerializer(new LinkedResourceUriSerializer());
				}
			}
			
			return beanProperties;
		}
	});
	
	setMixInAnnotation(EntityModel.class, ResourceMixin.class);
	setMixInAnnotation(MethodHandler.class, MethodHandlerMixin.class);
}
 
Example #8
Source Project: botbuilder-java   Author: microsoft   File: AdditionalPropertiesDeserializer.java    License: MIT License 6 votes vote down vote up
/**
 * Gets a module wrapping this serializer as an adapter for the Jackson
 * ObjectMapper.
 *
 * @param mapper the object mapper for default deserializations
 * @return a simple module to be plugged onto Jackson ObjectMapper.
 */
public static SimpleModule getModule(final ObjectMapper mapper) {
    SimpleModule module = new SimpleModule();
    module.setDeserializerModifier(new BeanDeserializerModifier() {
        @Override
        public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc, JsonDeserializer<?> deserializer) {
            for (Class<?> c : TypeToken.of(beanDesc.getBeanClass()).getTypes().classes().rawTypes()) {
                Field[] fields = c.getDeclaredFields();
                for (Field field : fields) {
                    if ("additionalProperties".equalsIgnoreCase(field.getName())) {
                        JsonProperty property = field.getAnnotation(JsonProperty.class);
                        if (property != null && property.value().isEmpty()) {
                            return new AdditionalPropertiesDeserializer(beanDesc.getBeanClass(), deserializer, mapper);
                        }
                    }
                }
            }
            return deserializer;
        }
    });
    return module;
}
 
Example #9
Source Project: albedo   Author: somowhere   File: CustomFieldModule.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void setupModule(Module.SetupContext context) {
	super.setupModule(context);

	context.addBeanSerializerModifier(new BeanSerializerModifier() {

		@Override
		public JsonSerializer<?> modifySerializer(
			SerializationConfig config,
			BeanDescription beanDesc,
			JsonSerializer<?> serializer) {
			if (serializer instanceof BeanSerializerBase) {
				return new ExtraFieldSerializer(
					(BeanSerializerBase) serializer);
			}
			return serializer;

		}
	});
}
 
Example #10
Source Project: aws-xray-sdk-java   Author: aws   File: EntityImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void setupModule(SetupContext setupContext) {
    super.setupModule(setupContext);
    setupContext.addBeanSerializerModifier(new BeanSerializerModifier() {
        @SuppressWarnings("unchecked")
        @Override
        public JsonSerializer<?> modifySerializer(
            SerializationConfig serializationConfig,
            BeanDescription beanDescription,
            JsonSerializer<?> jsonSerializer) {
            Class<?> beanClass = beanDescription.getBeanClass();
            if (Cause.class.isAssignableFrom(beanClass)) {
                return new CauseSerializer((JsonSerializer<Object>) jsonSerializer);
            } else if (StackTraceElement.class.isAssignableFrom(beanClass)) {
                return new StackTraceElementSerializer();
            }
            return jsonSerializer;
        }
    });
}
 
Example #11
Source Project: spring-cloud-netflix   Author: spring-cloud   File: RestTemplateTransportClientFactory.java    License: Apache License 2.0 6 votes vote down vote up
public static BeanSerializerModifier createJsonSerializerModifier() { // final
	// KeyFormatter
	// keyFormatter,
	// final
	// boolean
	// compactMode)
	// {
	return new BeanSerializerModifier() {
		@Override
		public JsonSerializer<?> modifySerializer(SerializationConfig config,
				BeanDescription beanDesc, JsonSerializer<?> serializer) {
			/*
			 * if (beanDesc.getBeanClass().isAssignableFrom(Applications.class)) {
			 * return new ApplicationsJsonBeanSerializer((BeanSerializerBase)
			 * serializer, keyFormatter); }
			 */
			if (beanDesc.getBeanClass().isAssignableFrom(InstanceInfo.class)) {
				return new InstanceInfoJsonBeanSerializer(
						(BeanSerializerBase) serializer, false);
			}
			return serializer;
		}
	};
}
 
Example #12
Source Project: autorest-clientruntime-for-java   Author: Azure   File: AdditionalPropertiesSerializer.java    License: MIT License 6 votes vote down vote up
/**
 * Gets a module wrapping this serializer as an adapter for the Jackson
 * ObjectMapper.
 *
 * @param mapper the object mapper for default serializations
 * @return a simple module to be plugged onto Jackson ObjectMapper.
 */
public static SimpleModule getModule(final ObjectMapper mapper) {
    SimpleModule module = new SimpleModule();
    module.setSerializerModifier(new BeanSerializerModifier() {
        @Override
        public JsonSerializer<?> modifySerializer(SerializationConfig config, BeanDescription beanDesc, JsonSerializer<?> serializer) {
            for (Class<?> c : TypeToken.of(beanDesc.getBeanClass()).getTypes().classes().rawTypes()) {
                if (c.isAssignableFrom(Object.class)) {
                    continue;
                }
                Field[] fields = c.getDeclaredFields();
                for (Field field : fields) {
                    if ("additionalProperties".equalsIgnoreCase(field.getName())) {
                        JsonProperty property = field.getAnnotation(JsonProperty.class);
                        if (property != null && property.value().isEmpty()) {
                            return new AdditionalPropertiesSerializer(beanDesc.getBeanClass(), serializer, mapper);
                        }
                    }
                }
            }
            return serializer;
        }
    });
    return module;
}
 
Example #13
Source Project: Flink-CEPplus   Author: ljygz   File: BeanDeserializerModifierForIgnorables.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public BeanDeserializerBuilder updateBuilder(
	DeserializationConfig config, BeanDescription beanDesc,
	BeanDeserializerBuilder builder) {
	if (!type.equals(beanDesc.getBeanClass())) {
		return builder;
	}

	for (String ignorable : ignorables) {
		builder.addIgnorable(ignorable);
	}
	return builder;
}
 
Example #14
Source Project: hawkular-alerts   Author: hawkular   File: JacksonDeserializer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<BeanPropertyDefinition> updateProperties(DeserializationConfig config,
        BeanDescription beanDesc, List<BeanPropertyDefinition> propDefs) {
    if (!thinnables.contains(beanDesc.getBeanClass())) {
        return propDefs;
    }
    List<BeanPropertyDefinition> newPropDefs = new ArrayList<>();
    for (BeanPropertyDefinition propDef : propDefs) {
        if (!ignorables.contains(propDef.getName())) {
            newPropDefs.add(propDef);
        }
    }
    return newPropDefs;
}
 
Example #15
Source Project: flink   Author: flink-tpc-ds   File: BeanDeserializerModifierForIgnorables.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public BeanDeserializerBuilder updateBuilder(
	DeserializationConfig config, BeanDescription beanDesc,
	BeanDeserializerBuilder builder) {
	if (!type.equals(beanDesc.getBeanClass())) {
		return builder;
	}

	for (String ignorable : ignorables) {
		builder.addIgnorable(ignorable);
	}
	return builder;
}
 
Example #16
Source Project: n2o-framework   Author: i-novus-llc   File: RestEngineTimeModule.java    License: Apache License 2.0 5 votes vote down vote up
public RestEngineTimeModule(String[] patterns) {
    this();
    setDeserializerModifier(new BeanDeserializerModifier() {
        @Override
        public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc, JsonDeserializer<?> deserializer) {
            if (beanDesc.getBeanClass() == String.class) {
                CustomDateDeserializer dateDeserializer = new CustomDateDeserializer(deserializer);
                dateDeserializer.setPatterns(patterns);
                return dateDeserializer;
            }
            return deserializer;
        }
    });
}
 
Example #17
Source Project: n2o-framework   Author: i-novus-llc   File: RestEngineTimeModule.java    License: Apache License 2.0 5 votes vote down vote up
public RestEngineTimeModule(String[] patterns, String[] exclusionKeys) {
    this();
    setDeserializerModifier(new BeanDeserializerModifier() {
        @Override
        public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc, JsonDeserializer<?> deserializer) {
            if (beanDesc.getBeanClass() == String.class) {
                CustomDateDeserializer dateDeserializer = new CustomDateDeserializer(deserializer);
                dateDeserializer.setPatterns(patterns);
                dateDeserializer.setExclusions(exclusionKeys);
                return dateDeserializer;
            }
            return deserializer;
        }
    });
}
 
Example #18
Source Project: hawkular-alerts   Author: hawkular   File: JacksonDeserializer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public BeanDeserializerBuilder updateBuilder(DeserializationConfig config, BeanDescription beanDesc,
        BeanDeserializerBuilder builder) {
    if (!thinnables.contains(beanDesc.getBeanClass())) {
        return builder;
    }
    for (String ignore : ignorables) {
        builder.addIgnorable(ignore);
    }
    return builder;
}
 
Example #19
Source Project: batfish   Author: batfish   File: BatfishThirdPartySerializers.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public @Nullable JsonSerializer<?> findSerializer(
    SerializationConfig config, JavaType type, BeanDescription beanDesc) {
  if (RangeSet.class.isAssignableFrom(type.getRawClass())) {
    return new RangeSetSerializer(type.findSuperType(RangeSet.class));
  }
  return null;
}
 
Example #20
Source Project: jackson-datatypes-collections   Author: FasterXML   File: HppcDeserializers.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public JsonDeserializer<?> findBeanDeserializer(JavaType type,
        DeserializationConfig config, BeanDescription beanDesc)
    throws JsonMappingException
{
    return HppcContainerDeserializers.findDeserializer(config, type);
}
 
Example #21
Source Project: vavr-jackson   Author: vavr-io   File: VavrSerializers.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public JsonSerializer<?> findReferenceSerializer(SerializationConfig config,
                                                 ReferenceType type, BeanDescription beanDesc,
                                                 TypeSerializer contentTypeSerializer, JsonSerializer<Object> contentValueSerializer) {
    Class<?> raw = type.getRawClass();
    if (Lazy.class.isAssignableFrom(raw)) {
        return new LazySerializer(type, type.getContentType(), contentTypeSerializer, contentValueSerializer);
    }
    if (Option.class.isAssignableFrom(raw)) {
        return new OptionSerializer(type, type.getContentType(), contentTypeSerializer, contentValueSerializer, settings.useOptionInPlainFormat());
    }
    return super.findReferenceSerializer(config, type, beanDesc, contentTypeSerializer, contentValueSerializer);
}
 
Example #22
Source Project: botbuilder-java   Author: microsoft   File: FlatteningSerializer.java    License: MIT License 5 votes vote down vote up
/**
 * Gets a module wrapping this serializer as an adapter for the Jackson
 * ObjectMapper.
 *
 * @param mapper the object mapper for default serializations
 * @return a simple module to be plugged onto Jackson ObjectMapper.
 */
public static SimpleModule getModule(final ObjectMapper mapper) {
    SimpleModule module = new SimpleModule();
    module.setSerializerModifier(new BeanSerializerModifier() {
        @Override
        public JsonSerializer<?> modifySerializer(SerializationConfig config, BeanDescription beanDesc, JsonSerializer<?> serializer) {
            if (BeanSerializer.class.isAssignableFrom(serializer.getClass())) {
                return new FlatteningSerializer(beanDesc.getBeanClass(), serializer, mapper);
            }
            return serializer;
        }
    });
    return module;
}
 
Example #23
Source Project: warp10-platform   Author: senx   File: JsonUtils.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public JsonSerializer<?> modifySerializer(SerializationConfig config, BeanDescription beanDesc, JsonSerializer<?> serializer) {
  if (serializer instanceof UnknownSerializer || serializer instanceof BeanSerializer) {
    return customEncodersSerializer;
  } else {
    return serializer;
  }
}
 
Example #24
Source Project: cyclops   Author: aol   File: CyclopsSerializers.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public JsonSerializer<?> findReferenceSerializer(SerializationConfig config, ReferenceType type, BeanDescription beanDesc, TypeSerializer contentTypeSerializer, JsonSerializer<Object> contentValueSerializer) {
  if (Option.class.isAssignableFrom(type.getRawClass())) {
    return new OptionSerializer(type,true,contentTypeSerializer,contentValueSerializer);
  }
  if (Eval.class.isAssignableFrom(type.getRawClass())) {
    return new EvalSerializer(type,true,contentTypeSerializer,contentValueSerializer);
  }
  if (Trampoline.class.isAssignableFrom(type.getRawClass())) {
    return new TrampolineSerializer(type,true,contentTypeSerializer,contentValueSerializer);
  }
  if (Ior.class.isAssignableFrom(type.getRawClass())) {
    return new IorSerializer();
  }
  if (Sealed2.class.isAssignableFrom(type.getRawClass())) {
    return new Sealed2Serializer();
  }
  if (Sealed3.class.isAssignableFrom(type.getRawClass())) {
    return new Sealed3Serializer();
  }
  if (Sealed4.class.isAssignableFrom(type.getRawClass())) {
    return new Sealed4Serializer();
  }
  if (Sealed5.class.isAssignableFrom(type.getRawClass())) {
    return new Sealed5Serializer();
  }
  if (Value.class.isAssignableFrom(type.getRawClass())) {
    return new ValueSerializer(type,true,contentTypeSerializer,contentValueSerializer);
  }

  return super.findReferenceSerializer(config, type, beanDesc, contentTypeSerializer, contentValueSerializer);
}
 
Example #25
Source Project: autorest-clientruntime-for-java   Author: Azure   File: FlatteningSerializer.java    License: MIT License 5 votes vote down vote up
/**
 * Gets a module wrapping this serializer as an adapter for the Jackson
 * ObjectMapper.
 *
 * @param mapper the object mapper for default serializations
 * @return a simple module to be plugged onto Jackson ObjectMapper.
 */
public static SimpleModule getModule(final ObjectMapper mapper) {
    SimpleModule module = new SimpleModule();
    module.setSerializerModifier(new BeanSerializerModifier() {
        @Override
        public JsonSerializer<?> modifySerializer(SerializationConfig config, BeanDescription beanDesc, JsonSerializer<?> serializer) {
            if (BeanSerializer.class.isAssignableFrom(serializer.getClass())) {
                return new FlatteningSerializer(beanDesc.getBeanClass(), serializer, mapper);
            }
            return serializer;
        }
    });
    return module;
}
 
Example #26
Source Project: endpoints-java   Author: cloudendpoints   File: ObjectMapperUtil.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public JsonSerializer<?> modifyMapSerializer(SerializationConfig config, MapType valueType,
    BeanDescription beanDesc, JsonSerializer<?> serializer) {
  if (serializer instanceof MapSerializer) {
    // TODO: We should probably be propagating the NON_EMPTY inclusion here, but it's breaking
    // discovery.
    return new DeepEmptyCheckingSerializer<>(serializer);
  }
  return serializer;
}
 
Example #27
Source Project: gravitee-management-rest-api   Author: gravitee-io   File: ObjectMapperResolver.java    License: Apache License 2.0 5 votes vote down vote up
public ObjectMapperResolver() {
    mapper = new GraviteeMapper();

    //because Permissions are represented as char[]
    mapper.enable(SerializationFeature.WRITE_CHAR_ARRAYS_AS_JSON_ARRAYS);

    // register filter provider
    registerFilterProvider();

    SimpleModule module = new SimpleModule();
    module.setDeserializerModifier(new BeanDeserializerModifier() {
        @Override
        public JsonDeserializer<Enum> modifyEnumDeserializer(DeserializationConfig config,
                                                             final JavaType type,
                                                             BeanDescription beanDesc,
                                                             final JsonDeserializer<?> deserializer) {
            return new JsonDeserializer<Enum>() {
                @Override
                public Enum deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
                    Class<? extends Enum> rawClass = (Class<Enum<?>>) type.getRawClass();
                    return Enum.valueOf(rawClass, jp.getValueAsString().toUpperCase());
                }
            };
        }
    });
    module.addSerializer(Enum.class, new StdSerializer<Enum>(Enum.class) {
        @Override
        public void serialize(Enum value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
            jgen.writeString(value.name().toLowerCase());
        }
    });
    mapper.registerModule(module);
    
    mapper.registerModule(new JavaTimeModule());
    mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
}
 
Example #28
Source Project: jackson-datatype-protobuf   Author: HubSpot   File: MessageDeserializerFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public JsonDeserializer<?> findBeanDeserializer(JavaType type, DeserializationConfig config, BeanDescription beanDesc)
        throws JsonMappingException {
  if (Message.class.isAssignableFrom(type.getRawClass())) {
    return getDeserializer((Class<? extends Message>) type.getRawClass()).buildAtEnd();
  } else if (Message.Builder.class.isAssignableFrom(type.getRawClass())) {
    return getDeserializer((Class<? extends Message>) type.getRawClass().getDeclaringClass());
  } else {
    return super.findBeanDeserializer(type, config, beanDesc);
  }
}
 
Example #29
Source Project: titus-control-plane   Author: Netflix   File: CompositeDeserializers.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public JsonDeserializer<?> findReferenceDeserializer(ReferenceType refType, DeserializationConfig config,
                                                     BeanDescription beanDesc, TypeDeserializer contentTypeDeserializer,
                                                     JsonDeserializer<?> contentDeserializer) throws JsonMappingException {
    for (Deserializers deserializers : deserializersList) {
        JsonDeserializer<?> deserializer = deserializers.findReferenceDeserializer(refType, config, beanDesc, contentTypeDeserializer, contentDeserializer);
        if (deserializer != null) {
            return deserializer;
        }
    }
    return null;
}
 
Example #30
Source Project: cyclops   Author: aol   File: CyclopsSerializers.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public JsonSerializer<?> findCollectionLikeSerializer(SerializationConfig config, CollectionLikeType type, BeanDescription beanDesc, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) {
    if (!Collection.class.isAssignableFrom(type.getRawClass()) && IterableX.class.isAssignableFrom(type.getRawClass())) {
        return new IterableXSerializer();
    }
  return super.findCollectionLikeSerializer(config, type, beanDesc, elementTypeSerializer, elementValueSerializer);
}