/** * @since 1.7 */ @SuppressWarnings("unchecked") protected SerializerBase(JavaType type) { _handledType = (Class<T>) type.getRawClass(); }
public AbstractDeserializer(JavaType bt) { _baseType = bt; Class<?> cls = bt.getRawClass(); _acceptString = cls.isAssignableFrom(String.class); _acceptBoolean = (cls == Boolean.TYPE) || cls.isAssignableFrom(Boolean.class); _acceptInt = (cls == Integer.TYPE) || cls.isAssignableFrom(Integer.class); _acceptDouble = (cls == Double.TYPE) || cls.isAssignableFrom(Double.class); }
@Override public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { // This method should never be called... throw ctxt.instantiationException(_baseType.getRawClass(), "abstract types can only be instantiated with additional type information"); }
public ObjectArrayDeserializer(ArrayType arrayType, JsonDeserializer<Object> elemDeser, TypeDeserializer elemTypeDeser) { super(Object[].class); _arrayType = arrayType; _elementClass = arrayType.getContentType().getRawClass(); _untyped = (_elementClass == Object.class); _elementDeserializer = elemDeser; _elementTypeDeserializer = elemTypeDeser; }
@Override public JsonDeserializer<?> findBeanDeserializer(JavaType type, DeserializationConfig config, DeserializerProvider provider, BeanDescription beanDesc, BeanProperty property) throws JsonMappingException { return (_classMappings == null) ? null : _classMappings.get(new ClassKey(type.getRawClass())); }
/** * @since 1.9.4 */ public String idFromBaseType() { return idFromValueAndType(null, _baseType.getRawClass()); } }
public static ArrayType construct(JavaType componentType, Object valueHandler, Object typeHandler) { /* This is bit messy: there is apparently no other way to * reconstruct actual concrete/raw array class from component * type, than to construct an instance, get class (same is * true for GenericArracyType as well; hence we won't bother * passing that in). */ Object emptyInstance = Array.newInstance(componentType.getRawClass(), 0); return new ArrayType(componentType, emptyInstance, null, null); }
@Override public JavaType findTypeMapping(DeserializationConfig config, JavaType type) { // this is the main mapping base, so let's Class<?> src = type.getRawClass(); Class<?> dst = _mappings.get(new ClassKey(src)); if (dst == null) { return null; } return type.narrowBy(dst); }
@Override public JavaType widenContentsBy(Class<?> contentClass) { // Can do a quick check first: if (contentClass == _componentType.getRawClass()) { return this; } return construct(_componentType.widenBy(contentClass), _valueHandler, _typeHandler); }
@Override public JavaType narrowContentsBy(Class<?> contentClass) { // Can do a quick check first: if (contentClass == _elementType.getRawClass()) { return this; } return new CollectionLikeType(_class, _elementType.narrowBy(contentClass), _valueHandler, _typeHandler); }
@Override public JavaType widenContentsBy(Class<?> contentClass) { // Can do a quick check first: if (contentClass == _elementType.getRawClass()) { return this; } return new CollectionType(_class, _elementType.widenBy(contentClass), _valueHandler, _typeHandler); }
@Override public JavaType narrowContentsBy(Class<?> contentClass) { // Can do a quick check first: if (contentClass == _valueType.getRawClass()) { return this; } return new MapType(_class, _keyType, _valueType.narrowBy(contentClass), _valueHandler, _typeHandler); }
@Override public JavaType narrowContentsBy(Class<?> contentClass) { // Can do a quick check first: if (contentClass == _elementType.getRawClass()) { return this; } return new CollectionType(_class, _elementType.narrowBy(contentClass), _valueHandler, _typeHandler); }
@Override public JavaType widenContentsBy(Class<?> contentClass) { if (contentClass == _valueType.getRawClass()) { return this; } return new MapLikeType(_class, _keyType, _valueType.widenBy(contentClass), _valueHandler, _typeHandler); }
@Override @SuppressWarnings("unchecked") public JsonSerializer<Object> createSerializer(SerializationConfig config, JavaType type, BeanProperty property) throws JsonMappingException { JsonSerializer<?> ser = findCustomSerializer(type.getRawClass(), config); if (ser != null) { return (JsonSerializer<Object>) ser; } return super.createSerializer(config, type, property); }
@Override public Class<?> getRawType() { if (_type instanceof Class<?>) { return (Class<?>) _type; } // 14-Mar-2011, tatu: Not optimal, but has to do for now... JavaType t = TypeFactory.defaultInstance().constructType(_type); return t.getRawClass(); }
protected JsonDeserializer<Object> _handleUnknownValueDeserializer(JavaType type) throws JsonMappingException { // Let's try to figure out the reason, to give better error Class<?> rawClass = type.getRawClass(); if (!ClassUtil.isConcrete(rawClass)) { throw new JsonMappingException("Can not find a Value deserializer for abstract type "+type); } throw new JsonMappingException("Can not find a Value deserializer for type "+type); }
public final SerializerAndMapResult findAndAddSerializer(JavaType type, SerializerProvider provider, BeanProperty property) throws JsonMappingException { JsonSerializer<Object> serializer = provider.findValueSerializer(type, property); return new SerializerAndMapResult(serializer, newWith(type.getRawClass(), serializer)); }
@Override public BasicBeanDescription forDirectClassAnnotations(MapperConfig<?> cfg, JavaType type, MixInResolver r) { boolean useAnnotations = cfg.isAnnotationProcessingEnabled(); AnnotationIntrospector ai = cfg.getAnnotationIntrospector(); AnnotatedClass ac = AnnotatedClass.constructWithoutSuperTypes(type.getRawClass(), (useAnnotations ? ai : null), r); return BasicBeanDescription.forOtherUse(cfg, type, ac); }
@Override public BasicBeanDescription forClassAnnotations(MapperConfig<?> cfg, JavaType type, MixInResolver r) { boolean useAnnotations = cfg.isAnnotationProcessingEnabled(); AnnotationIntrospector ai = cfg.getAnnotationIntrospector(); AnnotatedClass ac = AnnotatedClass.construct(type.getRawClass(), (useAnnotations ? ai : null), r); return BasicBeanDescription.forOtherUse(cfg, type, ac); }