/** * Factory method for constructing an "empty" serializer; one that * outputs no properties (but handles JSON objects properly, including * type information) */ public BeanSerializer createDummy() { return BeanSerializer.createDummy(_beanDesc.getBeanClass()); } }
protected boolean isFactoryMethod(AnnotatedMethod am) { /* First: return type must be compatible with the introspected class * (i.e. allowed to be sub-class, although usually is the same * class) */ Class<?> rt = am.getRawType(); if (!getBeanClass().isAssignableFrom(rt)) { return false; } /* Also: must be a recognized factory method, meaning: * (a) marked with @JsonCreator annotation, or * (a) "valueOf" (at this point, need not be public) */ if (_annotationIntrospector.hasCreatorAnnotation(am)) { return true; } if ("valueOf".equals(am.getName())) { return true; } return false; }
/** * Factory method for constructing an "empty" serializer; one that * outputs no properties (but handles JSON objects properly, including * type information) */ public BeanSerializer createDummy() { return BeanSerializer.createDummy(_beanDesc.getBeanClass()); } }
if (beanDesc.getBeanClass() == Object.class) { throw new IllegalArgumentException("Can not create bean serializer for Object.class");
protected boolean isFactoryMethod(AnnotatedMethod am) { /* First: return type must be compatible with the introspected class * (i.e. allowed to be sub-class, although usually is the same * class) */ Class<?> rt = am.getRawType(); if (!getBeanClass().isAssignableFrom(rt)) { return false; } /* Also: must be a recognized factory method, meaning: * (a) marked with @JsonCreator annotation, or * (a) "valueOf" (at this point, need not be public) */ if (_annotationIntrospector.hasCreatorAnnotation(am)) { return true; } if ("valueOf".equals(am.getName())) { return true; } return false; }
/** * Factory method for constructing an "empty" serializer; one that * outputs no properties (but handles JSON objects properly, including * type information) */ public BeanSerializer createDummy() { return BeanSerializer.createDummy(_beanDesc.getBeanClass()); } }
/** * Factory method for constructing an "empty" serializer; one that * outputs no properties (but handles JSON objects properly, including * type information) */ public BeanSerializer createDummy() { return BeanSerializer.createDummy(_beanDesc.getBeanClass()); } }
/** * Factory method for constructing an "empty" serializer; one that * outputs no properties (but handles JSON objects properly, including * type information) */ public BeanSerializer createDummy() { return BeanSerializer.createDummy(_beanDesc.getBeanClass()); } }
public Creator.StringBased stringCreator() { if (_strConstructor == null && _strFactory == null) { return null; } return new Creator.StringBased(_beanDesc.getBeanClass(), _strConstructor, _strFactory); }
public Creator.NumberBased numberCreator() { if (_intConstructor == null && _intFactory == null && _longConstructor == null && _longFactory == null) { return null; } return new Creator.NumberBased(_beanDesc.getBeanClass(), _intConstructor, _intFactory, _longConstructor, _longFactory); }
if (beanDesc.getBeanClass() == Object.class) { throw new IllegalArgumentException("Can not create bean serializer for Object.class");
protected boolean isFactoryMethod(AnnotatedMethod am) { /* First: return type must be compatible with the introspected class * (i.e. allowed to be sub-class, although usually is the same * class) */ Class<?> rt = am.getRawType(); if (!getBeanClass().isAssignableFrom(rt)) { return false; } /* Also: must be a recognized factory method, meaning: * (a) marked with @JsonCreator annotation, or * (a) "valueOf" (at this point, need not be public) */ if (_annotationIntrospector.hasCreatorAnnotation(am)) { return true; } if ("valueOf".equals(am.getName())) { return true; } return false; }
protected boolean isFactoryMethod(AnnotatedMethod am) { /* First: return type must be compatible with the introspected class * (i.e. allowed to be sub-class, although usually is the same * class) */ Class<?> rt = am.getRawType(); if (!getBeanClass().isAssignableFrom(rt)) { return false; } /* Also: must be a recognized factory method, meaning: * (a) marked with @JsonCreator annotation, or * (a) "valueOf" (at this point, need not be public) */ if (_annotationIntrospector.hasCreatorAnnotation(am)) { return true; } if ("valueOf".equals(am.getName())) { return true; } return false; }
protected boolean isFactoryMethod(AnnotatedMethod am) { /* First: return type must be compatible with the introspected class * (i.e. allowed to be sub-class, although usually is the same * class) */ Class<?> rt = am.getReturnType(); if (!getBeanClass().isAssignableFrom(rt)) { return false; } /* Also: must be a recognized factory method, meaning: * (a) marked with @JsonCreator annotation, or * (a) "valueOf" (at this point, need not be public) */ if (_annotationIntrospector.hasCreatorAnnotation(am)) { return true; } if ("valueOf".equals(am.getName())) { return true; } return false; }
protected boolean isFactoryMethod(AnnotatedMethod am) { /* First: return type must be compatible with the introspected class * (i.e. allowed to be sub-class, although usually is the same * class) */ Class<?> rt = am.getRawType(); if (!getBeanClass().isAssignableFrom(rt)) { return false; } /* Also: must be a recognized factory method, meaning: * (a) marked with @JsonCreator annotation, or * (a) "valueOf" (at this point, need not be public) */ if (_annotationIntrospector.hasCreatorAnnotation(am)) { return true; } if ("valueOf".equals(am.getName())) { return true; } return false; }
Class<?>[] interfaces = beanDesc.getBeanClass().getInterfaces(); if (interfaces.length == 1) { synchronized (serializerClasses) { return new ClassTypeFieldSerializer(interfaces[0], (BeanSerializerBase) serializer); else return new NoPropertiesSerializer(interfaces[0], beanDesc.getBeanClass());
/** * Method that will construct a property object that represents * a logical property passed via Creator (constructor or static * factory method) */ protected SettableBeanProperty constructCreatorProperty(DeserializationConfig config, BasicBeanDescription beanDesc, String name, int index, AnnotatedParameter param) throws JsonMappingException { JavaType type = resolveType(config, beanDesc, param.getParameterType(), param); // Is there an annotation that specifies exact deserializer? JsonDeserializer<Object> deser = findDeserializerFromAnnotation(config, param); // If yes, we are mostly done: if (deser != null) { SettableBeanProperty.CreatorProperty prop = new SettableBeanProperty.CreatorProperty(name, type, beanDesc.getBeanClass(), index); prop.setValueDeserializer(deser); return prop; } // Otherwise may have other type specifying annotations type = modifyTypeByAnnotation(config, param, type); return new SettableBeanProperty.CreatorProperty(name, type, beanDesc.getBeanClass(), index); } }
throws JsonMappingException Class<?> mapClass = beanDesc.getBeanClass(); AnnotationIntrospector intr = config.getAnnotationIntrospector(); boolean fixAccess = config.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS);
/** * Method that is to find all creators (constructors, factory methods) * for the bean type to deserialize. */ protected void addDeserializerCreators(DeserializationConfig config, BasicBeanDescription beanDesc, BeanDeserializer deser) throws JsonMappingException { AnnotationIntrospector intr = config.getAnnotationIntrospector(); boolean fixAccess = config.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS); // First, let's figure out constructor/factor- based instantation Constructor<?> defaultCtor = beanDesc.findDefaultConstructor(); if (defaultCtor != null) { if (fixAccess) { ClassUtil.checkAndFixAccess(defaultCtor); } deser.setDefaultConstructor(defaultCtor); } CreatorContainer creators = new CreatorContainer(beanDesc.getBeanClass(), fixAccess); _addDeserializerConstructors(config, beanDesc, deser, intr, creators); _addDeserializerFactoryMethods(config, beanDesc, deser, intr, creators); deser.setCreators(creators); }
if (beanDesc.getBeanClass() == Object.class) { throw new IllegalArgumentException("Can not create bean serializer for Object.class");