本文整理汇总了Java中com.fasterxml.jackson.databind.ser.ContextualSerializer类的典型用法代码示例。如果您正苦于以下问题:Java ContextualSerializer类的具体用法?Java ContextualSerializer怎么用?Java ContextualSerializer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContextualSerializer类属于com.fasterxml.jackson.databind.ser包,在下文中一共展示了ContextualSerializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createContextual
import com.fasterxml.jackson.databind.ser.ContextualSerializer; //导入依赖的package包/类
public JsonSerializer<?> createContextual(SerializerProvider paramSerializerProvider, BeanProperty paramBeanProperty)
{
JsonSerializer localJsonSerializer1 = this._valueSerializer;
if (localJsonSerializer1 == null)
{
if ((paramSerializerProvider.isEnabled(MapperFeature.USE_STATIC_TYPING)) || (Modifier.isFinal(this._accessorMethod.getReturnType().getModifiers())))
{
JavaType localJavaType = paramSerializerProvider.constructType(this._accessorMethod.getGenericReturnType());
JsonSerializer localJsonSerializer2 = paramSerializerProvider.findTypedValueSerializer(localJavaType, false, this._property);
return withResolved(paramBeanProperty, localJsonSerializer2, isNaturalTypeWithStdHandling(localJavaType.getRawClass(), localJsonSerializer2));
}
}
else if ((localJsonSerializer1 instanceof ContextualSerializer))
return withResolved(paramBeanProperty, ((ContextualSerializer)localJsonSerializer1).createContextual(paramSerializerProvider, paramBeanProperty), this._forceTypeInformation);
return this;
}
示例2: createContextual
import com.fasterxml.jackson.databind.ser.ContextualSerializer; //导入依赖的package包/类
public JsonSerializer<?> createContextual(SerializerProvider paramSerializerProvider, BeanProperty paramBeanProperty)
{
if (this._delegateSerializer != null)
{
if ((this._delegateSerializer instanceof ContextualSerializer))
{
JsonSerializer localJsonSerializer = ((ContextualSerializer)this._delegateSerializer).createContextual(paramSerializerProvider, paramBeanProperty);
if (localJsonSerializer == this._delegateSerializer)
return this;
return withDelegate(this._converter, this._delegateType, localJsonSerializer);
}
return this;
}
JavaType localJavaType1 = this._delegateType;
JavaType localJavaType2 = localJavaType1;
if (localJavaType1 == null)
localJavaType2 = this._converter.getOutputType(paramSerializerProvider.getTypeFactory());
return withDelegate(this._converter, localJavaType2, paramSerializerProvider.findValueSerializer(localJavaType2, paramBeanProperty));
}
示例3: createContextual
import com.fasterxml.jackson.databind.ser.ContextualSerializer; //导入依赖的package包/类
@Override
public JsonSerializer<?> createContextual(SerializerProvider provider, BeanProperty property)
throws JsonMappingException {
if (delegate instanceof ContextualSerializer) {
return new DeepEmptyCheckingSerializer<>(
((ContextualSerializer) delegate).createContextual(provider, property));
}
return this;
}
示例4: createContextual
import com.fasterxml.jackson.databind.ser.ContextualSerializer; //导入依赖的package包/类
/**
* Override to preserve the delegating behavior when a contextualized serializer is created.
*/
@Override
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property)
throws JsonMappingException {
if (_delegateSerializer instanceof ContextualSerializer) {
JsonSerializer<?> contextualDelegate = ((ContextualSerializer) _delegateSerializer).createContextual(prov, property);
// Check for different instance
if (contextualDelegate != _delegateSerializer) {
return new DelegatingMapSerializer(contextualDelegate);
}
}
return this;
}
示例5: createContextual
import com.fasterxml.jackson.databind.ser.ContextualSerializer; //导入依赖的package包/类
public JsonSerializer<?> createContextual(SerializerProvider paramSerializerProvider, BeanProperty paramBeanProperty)
{
TypeSerializer localTypeSerializer1 = this._valueTypeSerializer;
TypeSerializer localTypeSerializer2 = localTypeSerializer1;
if (localTypeSerializer1 != null)
localTypeSerializer2 = localTypeSerializer2.forProperty(paramBeanProperty);
JsonSerializer localJsonSerializer1 = null;
if (paramBeanProperty != null)
{
AnnotatedMember localAnnotatedMember = paramBeanProperty.getMember();
localJsonSerializer1 = null;
if (localAnnotatedMember != null)
{
Object localObject = paramSerializerProvider.getAnnotationIntrospector().findContentSerializer(localAnnotatedMember);
localJsonSerializer1 = null;
if (localObject != null)
localJsonSerializer1 = paramSerializerProvider.serializerInstance(localAnnotatedMember, localObject);
}
}
if (localJsonSerializer1 == null)
localJsonSerializer1 = this._elementSerializer;
JsonSerializer localJsonSerializer2 = findConvertingContentSerializer(paramSerializerProvider, paramBeanProperty, localJsonSerializer1);
JsonSerializer localJsonSerializer3 = localJsonSerializer2;
if (localJsonSerializer2 == null)
{
if ((this._elementType != null) && ((this._staticTyping) || (hasContentTypeAnnotation(paramSerializerProvider, paramBeanProperty))))
localJsonSerializer3 = paramSerializerProvider.findValueSerializer(this._elementType, paramBeanProperty);
}
else if ((localJsonSerializer3 instanceof ContextualSerializer))
localJsonSerializer3 = ((ContextualSerializer)localJsonSerializer3).createContextual(paramSerializerProvider, paramBeanProperty);
return withResolved(paramBeanProperty, localTypeSerializer2, localJsonSerializer3);
}
示例6: createContextual
import com.fasterxml.jackson.databind.ser.ContextualSerializer; //导入依赖的package包/类
public JsonSerializer<?> createContextual(SerializerProvider paramSerializerProvider, BeanProperty paramBeanProperty)
{
TypeSerializer localTypeSerializer1 = this._valueTypeSerializer;
TypeSerializer localTypeSerializer2 = localTypeSerializer1;
if (localTypeSerializer1 != null)
localTypeSerializer2 = localTypeSerializer2.forProperty(paramBeanProperty);
JsonSerializer localJsonSerializer1 = null;
if (paramBeanProperty != null)
{
AnnotatedMember localAnnotatedMember = paramBeanProperty.getMember();
localJsonSerializer1 = null;
if (localAnnotatedMember != null)
{
Object localObject = paramSerializerProvider.getAnnotationIntrospector().findContentSerializer(localAnnotatedMember);
localJsonSerializer1 = null;
if (localObject != null)
localJsonSerializer1 = paramSerializerProvider.serializerInstance(localAnnotatedMember, localObject);
}
}
if (localJsonSerializer1 == null)
localJsonSerializer1 = this._elementSerializer;
JsonSerializer localJsonSerializer2 = findConvertingContentSerializer(paramSerializerProvider, paramBeanProperty, localJsonSerializer1);
JsonSerializer localJsonSerializer3 = localJsonSerializer2;
if (localJsonSerializer2 == null)
{
if ((localJsonSerializer3 == null) && (this._elementType != null) && ((this._staticTyping) || (hasContentTypeAnnotation(paramSerializerProvider, paramBeanProperty))))
localJsonSerializer3 = paramSerializerProvider.findValueSerializer(this._elementType, paramBeanProperty);
}
else if ((localJsonSerializer3 instanceof ContextualSerializer))
localJsonSerializer3 = ((ContextualSerializer)localJsonSerializer3).createContextual(paramSerializerProvider, paramBeanProperty);
if ((localJsonSerializer3 != this._elementSerializer) || (paramBeanProperty != this._property) || (this._valueTypeSerializer != localTypeSerializer2))
return withResolved(paramBeanProperty, localTypeSerializer2, localJsonSerializer3);
return this;
}
示例7: createContextual
import com.fasterxml.jackson.databind.ser.ContextualSerializer; //导入依赖的package包/类
public JsonSerializer<?> createContextual(SerializerProvider paramSerializerProvider, BeanProperty paramBeanProperty)
{
JsonSerializer localJsonSerializer1 = null;
if (paramBeanProperty != null)
{
AnnotatedMember localAnnotatedMember = paramBeanProperty.getMember();
localJsonSerializer1 = null;
if (localAnnotatedMember != null)
{
Object localObject = paramSerializerProvider.getAnnotationIntrospector().findContentSerializer(localAnnotatedMember);
localJsonSerializer1 = null;
if (localObject != null)
localJsonSerializer1 = paramSerializerProvider.serializerInstance(localAnnotatedMember, localObject);
}
}
if (localJsonSerializer1 == null)
localJsonSerializer1 = this._valueSerializer;
JsonSerializer localJsonSerializer2 = findConvertingContentSerializer(paramSerializerProvider, paramBeanProperty, localJsonSerializer1);
JsonSerializer localJsonSerializer3 = localJsonSerializer2;
if (localJsonSerializer2 == null)
{
if (this._staticTyping)
return withValueSerializer(paramBeanProperty, paramSerializerProvider.findValueSerializer(this._valueType, paramBeanProperty));
}
else if ((this._valueSerializer instanceof ContextualSerializer))
localJsonSerializer3 = ((ContextualSerializer)localJsonSerializer3).createContextual(paramSerializerProvider, paramBeanProperty);
if (localJsonSerializer3 != this._valueSerializer)
return withValueSerializer(paramBeanProperty, localJsonSerializer3);
return this;
}
示例8: createContextual
import com.fasterxml.jackson.databind.ser.ContextualSerializer; //导入依赖的package包/类
public final JsonSerializer<?> createContextual(SerializerProvider paramSerializerProvider, BeanProperty paramBeanProperty)
{
JsonSerializer localJsonSerializer1 = null;
if (paramBeanProperty != null)
{
AnnotatedMember localAnnotatedMember = paramBeanProperty.getMember();
localJsonSerializer1 = null;
if (localAnnotatedMember != null)
{
Object localObject = paramSerializerProvider.getAnnotationIntrospector().findContentSerializer(localAnnotatedMember);
localJsonSerializer1 = null;
if (localObject != null)
localJsonSerializer1 = paramSerializerProvider.serializerInstance(localAnnotatedMember, localObject);
}
}
if (localJsonSerializer1 == null)
localJsonSerializer1 = this._serializer;
JsonSerializer localJsonSerializer2 = findConvertingContentSerializer(paramSerializerProvider, paramBeanProperty, localJsonSerializer1);
JsonSerializer localJsonSerializer3 = localJsonSerializer2;
if (localJsonSerializer2 == null)
localJsonSerializer3 = paramSerializerProvider.findValueSerializer(String.class, paramBeanProperty);
else if ((localJsonSerializer3 instanceof ContextualSerializer))
localJsonSerializer3 = ((ContextualSerializer)localJsonSerializer3).createContextual(paramSerializerProvider, paramBeanProperty);
if (isDefaultSerializer(localJsonSerializer3))
localJsonSerializer3 = null;
if (localJsonSerializer3 == this._serializer)
return this;
return new IndexedStringListSerializer(localJsonSerializer3);
}
示例9: createContextual
import com.fasterxml.jackson.databind.ser.ContextualSerializer; //导入依赖的package包/类
public JsonSerializer<?> createContextual(SerializerProvider paramSerializerProvider, BeanProperty paramBeanProperty)
{
JsonSerializer localJsonSerializer1 = null;
if (paramBeanProperty != null)
{
AnnotatedMember localAnnotatedMember = paramBeanProperty.getMember();
localJsonSerializer1 = null;
if (localAnnotatedMember != null)
{
Object localObject = paramSerializerProvider.getAnnotationIntrospector().findContentSerializer(localAnnotatedMember);
localJsonSerializer1 = null;
if (localObject != null)
localJsonSerializer1 = paramSerializerProvider.serializerInstance(localAnnotatedMember, localObject);
}
}
if (localJsonSerializer1 == null)
localJsonSerializer1 = this._serializer;
JsonSerializer localJsonSerializer2 = findConvertingContentSerializer(paramSerializerProvider, paramBeanProperty, localJsonSerializer1);
JsonSerializer localJsonSerializer3 = localJsonSerializer2;
if (localJsonSerializer2 == null)
localJsonSerializer3 = paramSerializerProvider.findValueSerializer(String.class, paramBeanProperty);
else if ((localJsonSerializer3 instanceof ContextualSerializer))
localJsonSerializer3 = ((ContextualSerializer)localJsonSerializer3).createContextual(paramSerializerProvider, paramBeanProperty);
if (isDefaultSerializer(localJsonSerializer3))
localJsonSerializer3 = null;
if (localJsonSerializer3 == this._serializer)
return this;
return new StringCollectionSerializer(localJsonSerializer3);
}
示例10: createContextual
import com.fasterxml.jackson.databind.ser.ContextualSerializer; //导入依赖的package包/类
public JsonSerializer<?> createContextual(SerializerProvider paramSerializerProvider, BeanProperty paramBeanProperty)
{
JsonSerializer localJsonSerializer1 = null;
if (paramBeanProperty != null)
{
AnnotatedMember localAnnotatedMember = paramBeanProperty.getMember();
localJsonSerializer1 = null;
if (localAnnotatedMember != null)
{
Object localObject = paramSerializerProvider.getAnnotationIntrospector().findContentSerializer(localAnnotatedMember);
localJsonSerializer1 = null;
if (localObject != null)
localJsonSerializer1 = paramSerializerProvider.serializerInstance(localAnnotatedMember, localObject);
}
}
if (localJsonSerializer1 == null)
localJsonSerializer1 = this._elementSerializer;
JsonSerializer localJsonSerializer2 = findConvertingContentSerializer(paramSerializerProvider, paramBeanProperty, localJsonSerializer1);
JsonSerializer localJsonSerializer3 = localJsonSerializer2;
if (localJsonSerializer2 == null)
localJsonSerializer3 = paramSerializerProvider.findValueSerializer(String.class, paramBeanProperty);
else if ((localJsonSerializer3 instanceof ContextualSerializer))
localJsonSerializer3 = ((ContextualSerializer)localJsonSerializer3).createContextual(paramSerializerProvider, paramBeanProperty);
if (isDefaultSerializer(localJsonSerializer3))
localJsonSerializer3 = null;
if (localJsonSerializer3 == this._elementSerializer)
return this;
return new StringArraySerializer(this, paramBeanProperty, localJsonSerializer3);
}
示例11: createContextual
import com.fasterxml.jackson.databind.ser.ContextualSerializer; //导入依赖的package包/类
/**
* We can try to find the actual serializer for value, if we can
* statically figure out what the result type must be.
*/
// @Override
public JsonSerializer<?> createContextual(SerializerProvider provider,
BeanProperty property)
throws JsonMappingException
{
JsonSerializer<?> ser = _valueSerializer;
if (ser == null) {
/* Can only assign serializer statically if the declared type is final:
* if not, we don't really know the actual type until we get the instance.
*/
// 10-Mar-2010, tatu: Except if static typing is to be used
if (provider.isEnabled(MapperFeature.USE_STATIC_TYPING)
|| Modifier.isFinal(_accessorMethod.getReturnType().getModifiers())) {
JavaType t = provider.constructType(_accessorMethod.getGenericReturnType());
// false -> no need to cache
/* 10-Mar-2010, tatu: Ideally we would actually separate out type
* serializer from value serializer; but, alas, there's no access
* to serializer factory at this point...
*/
/* 09-Dec-2010, tatu: Turns out we must add special handling for
* cases where "native" (aka "natural") type is being serialized,
* using standard serializer
*/
ser = provider.findTypedValueSerializer(t, false, _property);
boolean forceTypeInformation = isNaturalTypeWithStdHandling(t.getRawClass(), ser);
return withResolved(property, ser, forceTypeInformation);
}
} else if (ser instanceof ContextualSerializer) {
ser = ((ContextualSerializer) ser).createContextual(provider, property);
return withResolved(property, ser, _forceTypeInformation);
}
return this;
}
示例12: createContextual
import com.fasterxml.jackson.databind.ser.ContextualSerializer; //导入依赖的package包/类
public JsonSerializer<?> createContextual(SerializerProvider provider,
BeanProperty property)
throws JsonMappingException
{
TypeSerializer vts = _valueTypeSerializer;
if (vts != null) {
vts = vts.forProperty(property);
}
/* 29-Sep-2012, tatu: Actually, we need to do much more contextual
* checking here since we finally know for sure the property,
* and it may have overrides
*/
JsonSerializer<?> ser = null;
// First: if we have a property, may have property-annotation overrides
if (property != null) {
AnnotatedMember m = property.getMember();
if (m != null) {
Object serDef = provider.getAnnotationIntrospector().findContentSerializer(m);
if (serDef != null) {
ser = provider.serializerInstance(m, serDef);
}
}
}
if (ser == null) {
ser = _elementSerializer;
}
if (ser == null) {
// 30-Sep-2012, tatu: One more thing -- if explicit content type is annotated,
// we can consider it a static case as well.
if (_elementType != null) {
if (_staticTyping || hasContentTypeAnnotation(provider, property)) {
ser = provider.findValueSerializer(_elementType, property);
}
}
} else if (ser instanceof ContextualSerializer) {
ser = ((ContextualSerializer) _elementSerializer).createContextual(provider, property);
}
return withResolved(property, vts, ser);
}
示例13: createContextual
import com.fasterxml.jackson.databind.ser.ContextualSerializer; //导入依赖的package包/类
public JsonSerializer<?> createContextual(SerializerProvider provider,
BeanProperty property)
throws JsonMappingException
{
/* 29-Sep-2012, tatu: Actually, we need to do much more contextual
* checking here since we finally know for sure the property,
* and it may have overrides
*/
JsonSerializer<?> ser = null;
// First: if we have a property, may have property-annotation overrides
if (property != null) {
AnnotatedMember m = property.getMember();
if (m != null) {
Object serDef = provider.getAnnotationIntrospector().findContentSerializer(m);
if (serDef != null) {
ser = provider.serializerInstance(m, serDef);
}
}
}
if (ser == null) {
ser = _valueSerializer;
}
if (ser == null) {
if (_staticTyping) {
return withValueSerializer(property, provider.findValueSerializer(_valueType, property));
}
} else if (_valueSerializer instanceof ContextualSerializer) {
ser = ((ContextualSerializer) ser).createContextual(provider, property);
}
if (ser != _valueSerializer) {
return withValueSerializer(property, ser);
}
return this;
}
示例14: createContextual
import com.fasterxml.jackson.databind.ser.ContextualSerializer; //导入依赖的package包/类
public JsonSerializer<?> createContextual(SerializerProvider provider,
BeanProperty property)
throws JsonMappingException
{
/* 29-Sep-2012, tatu: Actually, we need to do much more contextual
* checking here since we finally know for sure the property,
* and it may have overrides
*/
JsonSerializer<?> ser = null;
// First: if we have a property, may have property-annotation overrides
if (property != null) {
AnnotatedMember m = property.getMember();
if (m != null) {
Object serDef = provider.getAnnotationIntrospector().findContentSerializer(m);
if (serDef != null) {
ser = provider.serializerInstance(m, serDef);
}
}
}
if (ser == null) {
ser = _serializer;
}
if (ser == null) {
ser = provider.findValueSerializer(String.class, property);
} else if (ser instanceof ContextualSerializer) {
ser = ((ContextualSerializer) ser).createContextual(provider, property);
}
// Optimization: default serializer just writes String, so we can avoid a call:
if (isDefaultSerializer(ser)) {
ser = null;
}
// note: will never have TypeSerializer, because Strings are "natural" type
if (ser == _serializer) {
return this;
}
return new IndexedStringListSerializer(ser);
}
示例15: createContextual
import com.fasterxml.jackson.databind.ser.ContextualSerializer; //导入依赖的package包/类
public JsonSerializer<?> createContextual(SerializerProvider provider,
BeanProperty property)
throws JsonMappingException
{
/* 29-Sep-2012, tatu: Actually, we need to do much more contextual
* checking here since we finally know for sure the property,
* and it may have overrides
*/
JsonSerializer<?> ser = null;
// First: if we have a property, may have property-annotation overrides
if (property != null) {
AnnotatedMember m = property.getMember();
if (m != null) {
Object serDef = provider.getAnnotationIntrospector().findContentSerializer(m);
if (serDef != null) {
ser = provider.serializerInstance(m, serDef);
}
}
}
if (ser == null) {
ser = _serializer;
}
if (ser == null) {
ser = provider.findValueSerializer(String.class, property);
} else if (ser instanceof ContextualSerializer) {
ser = ((ContextualSerializer) ser).createContextual(provider, property);
}
// Optimization: default serializer just writes String, so we can avoid a call:
if (isDefaultSerializer(ser)) {
ser = null;
}
// note: will never have TypeSerializer, because Strings are "natural" type
if (ser == _serializer) {
return this;
}
return new StringCollectionSerializer(ser);
}