本文整理了Java中com.fasterxml.jackson.databind.JsonSerializer.handledType()
方法的一些代码示例,展示了JsonSerializer.handledType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonSerializer.handledType()
方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.JsonSerializer
类名称:JsonSerializer
方法名:handledType
[英]Method for accessing type of Objects this serializer can handle. Note that this information is not guaranteed to be exact -- it may be a more generic (super-type) -- but it should not be incorrect (return a non-related type).
Default implementation will return null, which essentially means same as returning Object.class
would; that is, that nothing is known about handled type.
[中]
代码示例来源:origin: spring-projects/spring-framework
/**
* Configure custom serializers. Each serializer is registered for the type
* returned by {@link JsonSerializer#handledType()}, which must not be {@code null}.
* @see #serializersByType(Map)
*/
public Jackson2ObjectMapperBuilder serializers(JsonSerializer<?>... serializers) {
for (JsonSerializer<?> serializer : serializers) {
Class<?> handledType = serializer.handledType();
if (handledType == null || handledType == Object.class) {
throw new IllegalArgumentException("Unknown handled type in " + serializer.getClass().getName());
}
this.serializers.put(serializer.handledType(), serializer);
}
return this;
}
代码示例来源:origin: org.springframework/spring-web
/**
* Configure custom serializers. Each serializer is registered for the type
* returned by {@link JsonSerializer#handledType()}, which must not be {@code null}.
* @see #serializersByType(Map)
*/
public Jackson2ObjectMapperBuilder serializers(JsonSerializer<?>... serializers) {
for (JsonSerializer<?> serializer : serializers) {
Class<?> handledType = serializer.handledType();
if (handledType == null || handledType == Object.class) {
throw new IllegalArgumentException("Unknown handled type in " + serializer.getClass().getName());
}
this.serializers.put(serializer.handledType(), serializer);
}
return this;
}
代码示例来源:origin: redisson/redisson
/**
* Method for adding given serializer for type that {@link JsonSerializer#handledType}
* specifies (which MUST return a non-null class; and can NOT be {@link Object}, as a
* sanity check).
* For serializers that do not declare handled type, use the variant that takes
* two arguments.
*
* @param ser
*/
public void addSerializer(JsonSerializer<?> ser)
{
// Interface to match?
Class<?> cls = ser.handledType();
if (cls == null || cls == Object.class) {
throw new IllegalArgumentException("JsonSerializer of type "+ser.getClass().getName()
+" does not define valid handledType() -- must either register with method that takes type argument "
+" or make serializer extend 'com.fasterxml.jackson.databind.ser.std.StdSerializer'");
}
_addSerializer(cls, ser);
}
代码示例来源:origin: redisson/redisson
throws IOException
Class<?> clz = handledType();
if (clz == null) {
clz = value.getClass();
代码示例来源:origin: io.airlift/json
public <T> void bindSerializer(JsonSerializer<T> jsonSerializer)
{
requireNonNull(jsonSerializer, "jsonSerializer is null");
Class<?> type = jsonSerializer.handledType();
requireNonNull(type, "jsonSerializer.handledType is null");
Preconditions.checkArgument(type == Object.class, "jsonSerializer.handledType can not be Object.class");
serializerMapBinder.addBinding(type).toInstance(jsonSerializer);
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-web
/**
* Configure custom serializers. Each serializer is registered for the type
* returned by {@link JsonSerializer#handledType()}, which must not be {@code null}.
* @see #serializersByType(Map)
*/
public Jackson2ObjectMapperBuilder serializers(JsonSerializer<?>... serializers) {
for (JsonSerializer<?> serializer : serializers) {
Class<?> handledType = serializer.handledType();
if (handledType == null || handledType == Object.class) {
throw new IllegalArgumentException("Unknown handled type in " + serializer.getClass().getName());
}
this.serializers.put(serializer.handledType(), serializer);
}
return this;
}
代码示例来源:origin: com.proofpoint.platform/json
public <T> void bindSerializer(JsonSerializer<T> jsonSerializer)
{
requireNonNull(jsonSerializer, "jsonSerializer is null");
Class<?> type = jsonSerializer.handledType();
requireNonNull(type, "jsonSerializer.handledType is null");
Preconditions.checkArgument(type == Object.class, "jsonSerializer.handledType can not be Object.class");
serializerMapBinder.addBinding(type).toInstance(jsonSerializer);
}
}
代码示例来源:origin: com.teradata.airlift/json
public <T> void bindSerializer(JsonSerializer<T> jsonSerializer)
{
Preconditions.checkNotNull(jsonSerializer, "jsonSerializer is null");
Class<?> type = jsonSerializer.handledType();
Preconditions.checkNotNull(type, "jsonSerializer.handledType is null");
Preconditions.checkArgument(type == Object.class, "jsonSerializer.handledType can not be Object.class");
serializerMapBinder.addBinding(type).toInstance(jsonSerializer);
}
}
代码示例来源:origin: airlift/airlift
public <T> void bindSerializer(JsonSerializer<T> jsonSerializer)
{
requireNonNull(jsonSerializer, "jsonSerializer is null");
Class<?> type = jsonSerializer.handledType();
requireNonNull(type, "jsonSerializer.handledType is null");
Preconditions.checkArgument(type == Object.class, "jsonSerializer.handledType can not be Object.class");
serializerMapBinder.addBinding(type).toInstance(jsonSerializer);
}
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Configure custom serializers. Each serializer is registered for the type
* returned by {@link JsonSerializer#handledType()}, which must not be {@code null}.
* @see #serializersByType(Map)
*/
public Jackson2ObjectMapperBuilder serializers(JsonSerializer<?>... serializers) {
for (JsonSerializer<?> serializer : serializers) {
Class<?> handledType = serializer.handledType();
if (handledType == null || handledType == Object.class) {
throw new IllegalArgumentException("Unknown handled type in " + serializer.getClass().getName());
}
this.serializers.put(serializer.handledType(), serializer);
}
return this;
}
代码示例来源:origin: com.bbossgroups/bboss-mvc
/**
* Configure custom serializers. Each serializer is registered for the type
* returned by {@link JsonSerializer#handledType()}, which must not be
* {@code null}.
* @see #serializersByType(Map)
*/
public Jackson2ObjectMapperBuilder serializers(JsonSerializer<?>... serializers) {
if (serializers != null) {
for (JsonSerializer<?> serializer : serializers) {
Class<?> handledType = serializer.handledType();
if (handledType == null || handledType == Object.class) {
throw new IllegalArgumentException("Unknown handled type in " + serializer.getClass().getName());
}
this.serializers.put(serializer.handledType(), serializer);
}
}
return this;
}
代码示例来源:origin: com.fasterxml.jackson.core/com.springsource.com.fasterxml.jackson.core.jackson-databind
throws IOException, JsonProcessingException
Class<?> clz = handledType();
if (clz == null) {
clz = value.getClass();
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
throws IOException, JsonProcessingException
Class<?> clz = handledType();
if (clz == null) {
clz = value.getClass();
代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all
/**
* Method for adding given serializer for type that {@link JsonSerializer#handledType}
* specifies (which MUST return a non-null class; and can NOT be {@link Object}, as a
* sanity check).
* For serializers that do not declare handled type, use the variant that takes
* two arguments.
*
* @param ser
*/
public void addSerializer(JsonSerializer<?> ser)
{
// Interface to match?
Class<?> cls = ser.handledType();
if (cls == null || cls == Object.class) {
throw new IllegalArgumentException("JsonSerializer of type "+ser.getClass().getName()
+" does not define valid handledType() -- must either register with method that takes type argument "
+" or make serializer extend 'com.fasterxml.jackson.databind.ser.std.StdSerializer'");
}
_addSerializer(cls, ser);
}
代码示例来源:origin: com.fasterxml.jackson.core/com.springsource.com.fasterxml.jackson.core.jackson-databind
/**
* Method for adding given serializer for type that {@link JsonSerializer#handledType}
* specifies (which MUST return a non-null class; and can NOT be {@link Object}, as a
* sanity check).
* For serializers that do not declare handled type, use the variant that takes
* two arguments.
*
* @param ser
*/
public void addSerializer(JsonSerializer<?> ser)
{
// Interface to match?
Class<?> cls = ser.handledType();
if (cls == null || cls == Object.class) {
throw new IllegalArgumentException("JsonSerializer of type "+ser.getClass().getName()
+" does not define valid handledType() -- must either register with method that takes type argument "
+" or make serializer extend 'com.fasterxml.jackson.databind.ser.std.SerializerBase'");
}
_addSerializer(cls, ser);
}
代码示例来源:origin: com.jwebmp.jackson.core/jackson-databind
/**
* Method for adding given serializer for type that {@link JsonSerializer#handledType}
* specifies (which MUST return a non-null class; and can NOT be {@link Object}, as a
* sanity check).
* For serializers that do not declare handled type, use the variant that takes
* two arguments.
*
* @param ser
*/
public void addSerializer(JsonSerializer<?> ser)
{
// Interface to match?
Class<?> cls = ser.handledType();
if (cls == null || cls == Object.class) {
throw new IllegalArgumentException("JsonSerializer of type "+ser.getClass().getName()
+" does not define valid handledType() -- must either register with method that takes type argument "
+" or make serializer extend 'com.fasterxml.jackson.databind.ser.std.StdSerializer'");
}
_addSerializer(cls, ser);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
/**
* Method for adding given serializer for type that {@link JsonSerializer#handledType}
* specifies (which MUST return a non-null class; and can NOT be {@link Object}, as a
* sanity check).
* For serializers that do not declare handled type, use the variant that takes
* two arguments.
*
* @param ser
*/
public void addSerializer(JsonSerializer<?> ser)
{
// Interface to match?
Class<?> cls = ser.handledType();
if (cls == null || cls == Object.class) {
throw new IllegalArgumentException("JsonSerializer of type "+ser.getClass().getName()
+" does not define valid handledType() -- must either register with method that takes type argument "
+" or make serializer extend 'com.fasterxml.jackson.databind.ser.std.StdSerializer'");
}
_addSerializer(cls, ser);
}
代码示例来源:origin: hstaudacher/osgi-jax-rs-connector
/**
* Method for adding given serializer for type that {@link JsonSerializer#handledType}
* specifies (which MUST return a non-null class; and can NOT be {@link Object}, as a
* sanity check).
* For serializers that do not declare handled type, use the variant that takes
* two arguments.
*
* @param ser
*/
public void addSerializer(JsonSerializer<?> ser)
{
// Interface to match?
Class<?> cls = ser.handledType();
if (cls == null || cls == Object.class) {
throw new IllegalArgumentException("JsonSerializer of type "+ser.getClass().getName()
+" does not define valid handledType() -- must either register with method that takes type argument "
+" or make serializer extend 'com.fasterxml.jackson.databind.ser.std.StdSerializer'");
}
_addSerializer(cls, ser);
}
代码示例来源:origin: Nextdoor/bender
/**
* Method for adding given serializer for type that {@link JsonSerializer#handledType}
* specifies (which MUST return a non-null class; and can NOT be {@link Object}, as a
* sanity check).
* For serializers that do not declare handled type, use the variant that takes
* two arguments.
*
* @param ser
*/
public void addSerializer(JsonSerializer<?> ser)
{
// Interface to match?
Class<?> cls = ser.handledType();
if (cls == null || cls == Object.class) {
throw new IllegalArgumentException("JsonSerializer of type "+ser.getClass().getName()
+" does not define valid handledType() -- must either register with method that takes type argument "
+" or make serializer extend 'com.fasterxml.jackson.databind.ser.std.StdSerializer'");
}
_addSerializer(cls, ser);
}
代码示例来源:origin: Nextdoor/bender
throws IOException
Class<?> clz = handledType();
if (clz == null) {
clz = value.getClass();
内容来源于网络,如有侵权,请联系作者删除!