org.codehaus.jackson.map.JsonSerializer.handledType()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(4.5k)|赞(0)|评价(0)|浏览(147)

本文整理了Java中org.codehaus.jackson.map.JsonSerializer.handledType()方法的一些代码示例,展示了JsonSerializer.handledType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonSerializer.handledType()方法的具体详情如下:
包路径:org.codehaus.jackson.map.JsonSerializer
类名称:JsonSerializer
方法名:handledType

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.
[中]方法访问此序列化程序可以处理的对象类型。请注意,此信息不能保证准确——它可能是更通用的(超级类型)——但不应该是错误的(返回一个不相关的类型)。
默认实现将返回null,这本质上与返回Object.class相同;也就是说,我们对句柄类型一无所知。

代码示例

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl

/**
 * 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 'org.codehaus.jackson.map.ser.std.SerializerBase'"); 
  }
  _addSerializer(cls, ser);
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * 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 'org.codehaus.jackson.map.ser.std.SerializerBase'"); 
  }
  _addSerializer(cls, ser);
}

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-lgpl

/**
 * 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 'org.codehaus.jackson.map.ser.std.SerializerBase'"); 
  }
  _addSerializer(cls, ser);
}

代码示例来源:origin: ovea-deprecated/jetty-session-redis

/**
 * 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 'org.codehaus.jackson.map.ser.std.SerializerBase'"); 
  }
  _addSerializer(cls, ser);
}

代码示例来源:origin: com.barchart.wrap/barchart-wrap-jackson

/**
 * 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 'org.codehaus.jackson.map.ser.std.SerializerBase'"); 
  }
  _addSerializer(cls, ser);
}

相关文章