public String idFromValue(Object paramObject) { Class localClass = paramObject.getClass(); String str1 = localClass.getName(); synchronized (this._typeToId) { String str2 = (String)this._typeToId.get(str1); if (str2 == null) { if (this._config.isAnnotationProcessingEnabled()) { BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)this._config.introspectClassAnnotations(localClass); str2 = this._config.getAnnotationIntrospector().findTypeName(localBasicBeanDescription.getClassInfo()); } if (str2 == null) str2 = _defaultTypeId(localClass); this._typeToId.put(str1, str2); } return str2; } }
protected List<BeanPropertyWriter> filterBeanProperties(SerializationConfig paramSerializationConfig, BasicBeanDescription paramBasicBeanDescription, List<BeanPropertyWriter> paramList) { String[] arrayOfString = paramSerializationConfig.getAnnotationIntrospector().findPropertiesToIgnore(paramBasicBeanDescription.getClassInfo()); if ((arrayOfString != null) && (arrayOfString.length > 0)) { HashSet localHashSet = ArrayBuilders.arrayToSet(arrayOfString); Iterator localIterator = paramList.iterator(); while (localIterator.hasNext()) { if (!localHashSet.contains(((BeanPropertyWriter)localIterator.next()).getName())) continue; localIterator.remove(); } } return paramList; }
public JsonSerializer<Object> findBeanSerializer(SerializationConfig paramSerializationConfig, JavaType paramJavaType, BasicBeanDescription paramBasicBeanDescription, BeanProperty paramBeanProperty) throws JsonMappingException { JsonSerializer localJsonSerializer; if (!isPotentialBeanType(paramJavaType.getRawClass())) localJsonSerializer = null; while (true) { return localJsonSerializer; localJsonSerializer = constructBeanSerializer(paramSerializationConfig, paramBasicBeanDescription, paramBeanProperty); if (!this._factoryConfig.hasSerializerModifiers()) continue; Iterator localIterator = this._factoryConfig.serializerModifiers().iterator(); while (localIterator.hasNext()) localJsonSerializer = ((BeanSerializerModifier)localIterator.next()).modifySerializer(paramSerializationConfig, paramBasicBeanDescription, localJsonSerializer); } }
protected <T extends AnnotatedMember> void removeIgnorableTypes(SerializationConfig paramSerializationConfig, BasicBeanDescription paramBasicBeanDescription, Map<String, T> paramMap) { if (paramMap.isEmpty()); while (true) { return; AnnotationIntrospector localAnnotationIntrospector = paramSerializationConfig.getAnnotationIntrospector(); Iterator localIterator = paramMap.entrySet().iterator(); HashMap localHashMap = new HashMap(); while (localIterator.hasNext()) { Class localClass = ((AnnotatedMember)((Map.Entry)localIterator.next()).getValue()).getRawType(); Boolean localBoolean = (Boolean)localHashMap.get(localClass); if (localBoolean == null) { localBoolean = localAnnotationIntrospector.isIgnorableType(((BasicBeanDescription)paramSerializationConfig.introspectClassAnnotations(localClass)).getClassInfo()); if (localBoolean == null) localBoolean = Boolean.FALSE; localHashMap.put(localClass, localBoolean); } if (!localBoolean.booleanValue()) continue; localIterator.remove(); } } }
protected JsonSerializer<?> buildCollectionSerializer(SerializationConfig paramSerializationConfig, CollectionType paramCollectionType, BasicBeanDescription paramBasicBeanDescription, BeanProperty paramBeanProperty, boolean paramBoolean, TypeSerializer paramTypeSerializer, JsonSerializer<Object> paramJsonSerializer) { Iterator localIterator = customSerializers().iterator(); while (localIterator.hasNext()) { JsonSerializer localJsonSerializer = ((Serializers)localIterator.next()).findCollectionSerializer(paramSerializationConfig, paramCollectionType, paramBasicBeanDescription, paramBeanProperty, paramTypeSerializer, paramJsonSerializer); if (localJsonSerializer != null) return localJsonSerializer; } Class localClass1 = paramCollectionType.getRawClass(); if (EnumSet.class.isAssignableFrom(localClass1)) return buildEnumSetSerializer(paramSerializationConfig, paramCollectionType, paramBasicBeanDescription, paramBeanProperty, paramBoolean, paramTypeSerializer, paramJsonSerializer); Class localClass2 = paramCollectionType.getContentType().getRawClass(); if (isIndexedList(localClass1)) { if (localClass2 == String.class) return new IndexedStringListSerializer(paramBeanProperty); return ContainerSerializers.indexedListSerializer(paramCollectionType.getContentType(), paramBoolean, paramTypeSerializer, paramBeanProperty, paramJsonSerializer); } if (localClass2 == String.class) return new StringCollectionSerializer(paramBeanProperty); return ContainerSerializers.collectionSerializer(paramCollectionType.getContentType(), paramBoolean, paramTypeSerializer, paramBeanProperty, paramJsonSerializer); }
public final JsonSerializer<?> findSerializerByLookup(JavaType paramJavaType, SerializationConfig paramSerializationConfig, BasicBeanDescription paramBasicBeanDescription, BeanProperty paramBeanProperty, boolean paramBoolean) { String str = paramJavaType.getRawClass().getName(); JsonSerializer localJsonSerializer1 = (JsonSerializer)_concrete.get(str); if (localJsonSerializer1 != null) return localJsonSerializer1; Class localClass = (Class)_concreteLazy.get(str); if (localClass != null) try { JsonSerializer localJsonSerializer2 = (JsonSerializer)localClass.newInstance(); return localJsonSerializer2; } catch (Exception localException) { throw new IllegalStateException("Failed to instantiate standard serializer (of type " + localClass.getName() + "): " + localException.getMessage(), localException); } return null; }
public JsonDeserializer<?> createCollectionLikeDeserializer(DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, CollectionLikeType paramCollectionLikeType, BeanProperty paramBeanProperty) throws JsonMappingException { CollectionLikeType localCollectionLikeType1 = (CollectionLikeType)mapAbstractType(paramDeserializationConfig, paramCollectionLikeType); BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspectClassAnnotations(localCollectionLikeType1.getRawClass()); JsonDeserializer localJsonDeserializer1 = findDeserializerFromAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), paramBeanProperty); if (localJsonDeserializer1 != null) return localJsonDeserializer1; CollectionLikeType localCollectionLikeType2 = (CollectionLikeType)modifyTypeByAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), localCollectionLikeType1, null); JavaType localJavaType = localCollectionLikeType2.getContentType(); JsonDeserializer localJsonDeserializer2 = (JsonDeserializer)localJavaType.getValueHandler(); TypeDeserializer localTypeDeserializer = (TypeDeserializer)localJavaType.getTypeHandler(); if (localTypeDeserializer == null) localTypeDeserializer = findTypeDeserializer(paramDeserializationConfig, localJavaType, paramBeanProperty); return _findCustomCollectionLikeDeserializer(localCollectionLikeType2, paramDeserializationConfig, paramDeserializerProvider, localBasicBeanDescription, paramBeanProperty, localTypeDeserializer, localJsonDeserializer2); }
public JsonDeserializer<?> createEnumDeserializer(DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, JavaType paramJavaType, BeanProperty paramBeanProperty) throws JsonMappingException { BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspectForCreation(paramJavaType); JsonDeserializer localJsonDeserializer1 = findDeserializerFromAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), paramBeanProperty); if (localJsonDeserializer1 != null) return localJsonDeserializer1; Class localClass = paramJavaType.getRawClass(); JsonDeserializer localJsonDeserializer2 = _findCustomEnumDeserializer(localClass, paramDeserializationConfig, localBasicBeanDescription, paramBeanProperty); if (localJsonDeserializer2 != null) return localJsonDeserializer2; Iterator localIterator = localBasicBeanDescription.getFactoryMethods().iterator(); while (localIterator.hasNext()) { AnnotatedMethod localAnnotatedMethod = (AnnotatedMethod)localIterator.next(); if (!paramDeserializationConfig.getAnnotationIntrospector().hasCreatorAnnotation(localAnnotatedMethod)) continue; if ((localAnnotatedMethod.getParameterCount() == 1) && (localAnnotatedMethod.getRawType().isAssignableFrom(localClass))) return EnumDeserializer.deserializerForCreator(paramDeserializationConfig, localClass, localAnnotatedMethod); throw new IllegalArgumentException("Unsuitable method (" + localAnnotatedMethod + ") decorated with @JsonCreator (for Enum type " + localClass.getName() + ")"); } return new EnumDeserializer(constructEnumResolver(localClass, paramDeserializationConfig)); }
public JsonDeserializer<?> createMapLikeDeserializer(DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, MapLikeType paramMapLikeType, BeanProperty paramBeanProperty) throws JsonMappingException { MapLikeType localMapLikeType1 = (MapLikeType)mapAbstractType(paramDeserializationConfig, paramMapLikeType); BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspectForCreation(localMapLikeType1); JsonDeserializer localJsonDeserializer1 = findDeserializerFromAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), paramBeanProperty); if (localJsonDeserializer1 != null) return localJsonDeserializer1; MapLikeType localMapLikeType2 = (MapLikeType)modifyTypeByAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), localMapLikeType1, null); JavaType localJavaType1 = localMapLikeType2.getKeyType(); JavaType localJavaType2 = localMapLikeType2.getContentType(); JsonDeserializer localJsonDeserializer2 = (JsonDeserializer)localJavaType2.getValueHandler(); KeyDeserializer localKeyDeserializer = (KeyDeserializer)localJavaType1.getValueHandler(); if (localKeyDeserializer == null) localKeyDeserializer = paramDeserializerProvider.findKeyDeserializer(paramDeserializationConfig, localJavaType1, paramBeanProperty); TypeDeserializer localTypeDeserializer = (TypeDeserializer)localJavaType2.getTypeHandler(); if (localTypeDeserializer == null) localTypeDeserializer = findTypeDeserializer(paramDeserializationConfig, localJavaType2, paramBeanProperty); return _findCustomMapLikeDeserializer(localMapLikeType2, paramDeserializationConfig, paramDeserializerProvider, localBasicBeanDescription, paramBeanProperty, localKeyDeserializer, localTypeDeserializer, localJsonDeserializer2); }
public TypeDeserializer findTypeDeserializer(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType, BeanProperty paramBeanProperty) { AnnotatedClass localAnnotatedClass = ((BasicBeanDescription)paramDeserializationConfig.introspectClassAnnotations(paramJavaType.getRawClass())).getClassInfo(); AnnotationIntrospector localAnnotationIntrospector = paramDeserializationConfig.getAnnotationIntrospector(); TypeResolverBuilder localTypeResolverBuilder = localAnnotationIntrospector.findTypeResolver(paramDeserializationConfig, localAnnotatedClass, paramJavaType); Collection localCollection; if (localTypeResolverBuilder == null) { localTypeResolverBuilder = paramDeserializationConfig.getDefaultTyper(paramJavaType); localCollection = null; if (localTypeResolverBuilder == null) return null; } else { localCollection = paramDeserializationConfig.getSubtypeResolver().collectAndResolveSubtypes(localAnnotatedClass, paramDeserializationConfig, localAnnotationIntrospector); } return localTypeResolverBuilder.buildTypeDeserializer(paramDeserializationConfig, paramJavaType, localCollection, paramBeanProperty); }
protected void addReferenceProperties(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription, BeanDeserializerBuilder paramBeanDeserializerBuilder) throws JsonMappingException { Map localMap = paramBasicBeanDescription.findBackReferenceProperties(); if (localMap != null) { Iterator localIterator = localMap.entrySet().iterator(); while (localIterator.hasNext()) { Map.Entry localEntry = (Map.Entry)localIterator.next(); String str = (String)localEntry.getKey(); AnnotatedMember localAnnotatedMember = (AnnotatedMember)localEntry.getValue(); if ((localAnnotatedMember instanceof AnnotatedMethod)) { paramBeanDeserializerBuilder.addBackReferenceProperty(str, constructSettableProperty(paramDeserializationConfig, paramBasicBeanDescription, localAnnotatedMember.getName(), (AnnotatedMethod)localAnnotatedMember)); continue; } paramBeanDeserializerBuilder.addBackReferenceProperty(str, constructSettableProperty(paramDeserializationConfig, paramBasicBeanDescription, localAnnotatedMember.getName(), (AnnotatedField)localAnnotatedMember)); } } }
public JsonDeserializer<Object> buildBeanDeserializer(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType, BasicBeanDescription paramBasicBeanDescription, BeanProperty paramBeanProperty) throws JsonMappingException { BeanDeserializerBuilder localBeanDeserializerBuilder = constructBeanDeserializerBuilder(paramBasicBeanDescription); localBeanDeserializerBuilder.setCreators(findDeserializerCreators(paramDeserializationConfig, paramBasicBeanDescription)); addBeanProps(paramDeserializationConfig, paramBasicBeanDescription, localBeanDeserializerBuilder); addReferenceProperties(paramDeserializationConfig, paramBasicBeanDescription, localBeanDeserializerBuilder); if (this._factoryConfig.hasDeserializerModifiers()) { Iterator localIterator2 = this._factoryConfig.deserializerModifiers().iterator(); while (localIterator2.hasNext()) localBeanDeserializerBuilder = ((BeanDeserializerModifier)localIterator2.next()).updateBuilder(paramDeserializationConfig, paramBasicBeanDescription, localBeanDeserializerBuilder); } JsonDeserializer localJsonDeserializer = localBeanDeserializerBuilder.build(paramBeanProperty); if (this._factoryConfig.hasDeserializerModifiers()) { Iterator localIterator1 = this._factoryConfig.deserializerModifiers().iterator(); while (localIterator1.hasNext()) localJsonDeserializer = ((BeanDeserializerModifier)localIterator1.next()).modifyDeserializer(paramDeserializationConfig, paramBasicBeanDescription, localJsonDeserializer); } return localJsonDeserializer; }
protected SettableAnyProperty constructAnySetter(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription, AnnotatedMethod paramAnnotatedMethod) throws JsonMappingException { if (paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) paramAnnotatedMethod.fixAccess(); JavaType localJavaType1 = paramBasicBeanDescription.bindingsForBeanType().resolveType(paramAnnotatedMethod.getParameterType(1)); BeanProperty.Std localStd = new BeanProperty.Std(paramAnnotatedMethod.getName(), localJavaType1, paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedMethod); JavaType localJavaType2 = resolveType(paramDeserializationConfig, paramBasicBeanDescription, localJavaType1, paramAnnotatedMethod, localStd); JsonDeserializer localJsonDeserializer = findDeserializerFromAnnotation(paramDeserializationConfig, paramAnnotatedMethod, localStd); if (localJsonDeserializer != null) { SettableAnyProperty localSettableAnyProperty = new SettableAnyProperty(localStd, paramAnnotatedMethod, localJavaType2); localSettableAnyProperty.setValueDeserializer(localJsonDeserializer); return localSettableAnyProperty; } return new SettableAnyProperty(localStd, paramAnnotatedMethod, modifyTypeByAnnotation(paramDeserializationConfig, paramAnnotatedMethod, localJavaType2, localStd.getName())); }
protected SettableBeanProperty constructSettableProperty(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription, String paramString, AnnotatedField paramAnnotatedField) throws JsonMappingException { if (paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) paramAnnotatedField.fixAccess(); JavaType localJavaType1 = paramBasicBeanDescription.bindingsForBeanType().resolveType(paramAnnotatedField.getGenericType()); BeanProperty.Std localStd = new BeanProperty.Std(paramString, localJavaType1, paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedField); JavaType localJavaType2 = resolveType(paramDeserializationConfig, paramBasicBeanDescription, localJavaType1, paramAnnotatedField, localStd); if (localJavaType2 != localJavaType1) localStd = localStd.withType(localJavaType2); JsonDeserializer localJsonDeserializer = findDeserializerFromAnnotation(paramDeserializationConfig, paramAnnotatedField, localStd); JavaType localJavaType3 = modifyTypeByAnnotation(paramDeserializationConfig, paramAnnotatedField, localJavaType2, paramString); SettableBeanProperty.FieldProperty localFieldProperty = new SettableBeanProperty.FieldProperty(paramString, localJavaType3, (TypeDeserializer)localJavaType3.getTypeHandler(), paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedField); if (localJsonDeserializer != null) localFieldProperty.setValueDeserializer(localJsonDeserializer); AnnotationIntrospector.ReferenceProperty localReferenceProperty = paramDeserializationConfig.getAnnotationIntrospector().findReferenceType(paramAnnotatedField); if ((localReferenceProperty != null) && (localReferenceProperty.isManagedReference())) localFieldProperty.setManagedReferenceName(localReferenceProperty.getName()); return localFieldProperty; }
protected SettableBeanProperty constructSettableProperty(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription, String paramString, AnnotatedMethod paramAnnotatedMethod) throws JsonMappingException { if (paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) paramAnnotatedMethod.fixAccess(); JavaType localJavaType1 = paramBasicBeanDescription.bindingsForBeanType().resolveType(paramAnnotatedMethod.getParameterType(0)); BeanProperty.Std localStd = new BeanProperty.Std(paramString, localJavaType1, paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedMethod); JavaType localJavaType2 = resolveType(paramDeserializationConfig, paramBasicBeanDescription, localJavaType1, paramAnnotatedMethod, localStd); if (localJavaType2 != localJavaType1) localStd = localStd.withType(localJavaType2); JsonDeserializer localJsonDeserializer = findDeserializerFromAnnotation(paramDeserializationConfig, paramAnnotatedMethod, localStd); JavaType localJavaType3 = modifyTypeByAnnotation(paramDeserializationConfig, paramAnnotatedMethod, localJavaType2, paramString); SettableBeanProperty.MethodProperty localMethodProperty = new SettableBeanProperty.MethodProperty(paramString, localJavaType3, (TypeDeserializer)localJavaType3.getTypeHandler(), paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedMethod); if (localJsonDeserializer != null) localMethodProperty.setValueDeserializer(localJsonDeserializer); AnnotationIntrospector.ReferenceProperty localReferenceProperty = paramDeserializationConfig.getAnnotationIntrospector().findReferenceType(paramAnnotatedMethod); if ((localReferenceProperty != null) && (localReferenceProperty.isManagedReference())) localMethodProperty.setManagedReferenceName(localReferenceProperty.getName()); return localMethodProperty; }
public KeyDeserializer createKeyDeserializer(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType, BeanProperty paramBeanProperty) throws JsonMappingException { if (this._factoryConfig.hasKeyDeserializers()) { BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspectClassAnnotations(paramJavaType.getRawClass()); Iterator localIterator = this._factoryConfig.keyDeserializers().iterator(); while (localIterator.hasNext()) { KeyDeserializer localKeyDeserializer = ((KeyDeserializers)localIterator.next()).findKeyDeserializer(paramJavaType, paramDeserializationConfig, localBasicBeanDescription, paramBeanProperty); if (localKeyDeserializer != null) return localKeyDeserializer; } } return null; }
protected CreatorContainer findDeserializerCreators(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription) throws JsonMappingException { boolean bool = paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS); CreatorContainer localCreatorContainer = new CreatorContainer(paramBasicBeanDescription, bool); AnnotationIntrospector localAnnotationIntrospector = paramDeserializationConfig.getAnnotationIntrospector(); if (paramBasicBeanDescription.getType().isConcrete()) { Constructor localConstructor = paramBasicBeanDescription.findDefaultConstructor(); if (localConstructor != null) { if (bool) ClassUtil.checkAndFixAccess(localConstructor); localCreatorContainer.setDefaultConstructor(localConstructor); } } VisibilityChecker localVisibilityChecker1 = paramDeserializationConfig.getDefaultVisibilityChecker(); if (!paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.AUTO_DETECT_CREATORS)) localVisibilityChecker1 = localVisibilityChecker1.withCreatorVisibility(JsonAutoDetect.Visibility.NONE); VisibilityChecker localVisibilityChecker2 = paramDeserializationConfig.getAnnotationIntrospector().findAutoDetectVisibility(paramBasicBeanDescription.getClassInfo(), localVisibilityChecker1); _addDeserializerConstructors(paramDeserializationConfig, paramBasicBeanDescription, localVisibilityChecker2, localAnnotationIntrospector, localCreatorContainer); _addDeserializerFactoryMethods(paramDeserializationConfig, paramBasicBeanDescription, localVisibilityChecker2, localAnnotationIntrospector, localCreatorContainer); return localCreatorContainer; }
public Delegating(BasicBeanDescription paramBasicBeanDescription, AnnotatedConstructor paramAnnotatedConstructor, AnnotatedMethod paramAnnotatedMethod) { TypeBindings localTypeBindings = paramBasicBeanDescription.bindingsForBeanType(); if (paramAnnotatedConstructor != null) { this._creator = paramAnnotatedConstructor; this._ctor = paramAnnotatedConstructor.getAnnotated(); this._factoryMethod = null; this._valueType = localTypeBindings.resolveType(paramAnnotatedConstructor.getParameterType(0)); return; } if (paramAnnotatedMethod != null) { this._creator = paramAnnotatedMethod; this._ctor = null; this._factoryMethod = paramAnnotatedMethod.getAnnotated(); this._valueType = localTypeBindings.resolveType(paramAnnotatedMethod.getParameterType(0)); return; } throw new IllegalArgumentException("Internal error: neither delegating constructor nor factory method passed"); }
/** * Method that will try to construct a {@link BeanSerializer} for * given class. Returns null if no properties are found. */ public JsonSerializer<Object> findBeanSerializer(JavaType type, SerializationConfig config, BasicBeanDescription beanDesc) { // First things first: we know some types are not beans... if (!isPotentialBeanType(type.getRawClass())) { return null; } // [JACKSON-80]: Support @JsonValue, alternative to bean method introspection. AnnotatedMethod valueMethod = beanDesc.findJsonValueMethod(); if (valueMethod != null) { /* Further, method itself may also be annotated to indicate * exact JsonSerializer to use for whatever value is returned... */ JsonSerializer<Object> ser = findSerializerFromAnnotation(config, valueMethod); return new JsonValueSerializer(valueMethod.getAnnotated(), ser); } return constructBeanSerializer(config, beanDesc); }
/** * Overridable method that can filter out properties. Default implementation * checks annotations class may have. */ protected List<BeanPropertyWriter> filterBeanProperties(SerializationConfig config, BasicBeanDescription beanDesc, List<BeanPropertyWriter> props) { AnnotationIntrospector intr = config.getAnnotationIntrospector(); AnnotatedClass ac = beanDesc.getClassInfo(); String[] ignored = intr.findPropertiesToIgnore(ac); if (ignored != null && ignored.length > 0) { HashSet<String> ignoredSet = ArrayBuilders.arrayToSet(ignored); Iterator<BeanPropertyWriter> it = props.iterator(); while (it.hasNext()) { if (ignoredSet.contains(it.next().getName())) { it.remove(); } } } return props; }
/** * Overridable method that will impose given partial ordering on * list of discovered propertied. Method can be overridden to * provide custom ordering of properties, beyond configurability * offered by annotations (whic allow alphabetic ordering, as * well as explicit ordering by providing array of property names). *<p> * By default Creator properties will be ordered before other * properties. Explicit custom ordering will override this implicit * default ordering. */ protected List<BeanPropertyWriter> sortBeanProperties(SerializationConfig config, BasicBeanDescription beanDesc, List<BeanPropertyWriter> props) { // Ok: so far so good. But do we need to (re)order these somehow? /* Yes; first, for [JACKSON-90] (explicit ordering and/or alphabetic) * and then for [JACKSON-170] (implicitly order creator properties before others) */ List<String> creatorProps = beanDesc.findCreatorPropertyNames(); // Then how about explicit ordering? AnnotationIntrospector intr = config.getAnnotationIntrospector(); AnnotatedClass ac = beanDesc.getClassInfo(); String[] propOrder = intr.findSerializationPropertyOrder(ac); Boolean alpha = intr.findSerializationSortAlphabetically(ac); boolean sort = (alpha != null) && alpha.booleanValue(); if (sort || !creatorProps.isEmpty() || propOrder != null) { props = _sortBeanProperties(props, creatorProps, propOrder, sort); } return props; }
public JsonDeserializer<?> createEnumDeserializer(DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, JavaType paramJavaType, BeanProperty paramBeanProperty) { BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspectForCreation(paramJavaType); JsonDeserializer localJsonDeserializer1 = findDeserializerFromAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), paramBeanProperty); if (localJsonDeserializer1 != null) return localJsonDeserializer1; Class localClass = paramJavaType.getRawClass(); JsonDeserializer localJsonDeserializer2 = _findCustomEnumDeserializer(localClass, paramDeserializationConfig, localBasicBeanDescription, paramBeanProperty); if (localJsonDeserializer2 != null) return localJsonDeserializer2; Iterator localIterator = localBasicBeanDescription.getFactoryMethods().iterator(); while (localIterator.hasNext()) { AnnotatedMethod localAnnotatedMethod = (AnnotatedMethod)localIterator.next(); if (paramDeserializationConfig.getAnnotationIntrospector().hasCreatorAnnotation(localAnnotatedMethod)) { if ((localAnnotatedMethod.getParameterCount() == 1) && (localAnnotatedMethod.getRawType().isAssignableFrom(localClass))) return EnumDeserializer.deserializerForCreator(paramDeserializationConfig, localClass, localAnnotatedMethod); throw new IllegalArgumentException("Unsuitable method (" + localAnnotatedMethod + ") decorated with @JsonCreator (for Enum type " + localClass.getName() + ")"); } } return new EnumDeserializer(constructEnumResolver(localClass, paramDeserializationConfig)); }
@Override @SuppressWarnings("unchecked") public JsonSerializer<Object> createSerializer(JavaType type, SerializationConfig config) { /* [JACKSON-220]: Very first thing, let's check annotations to * see if we have explicit definition */ BasicBeanDescription beanDesc = config.introspect(type.getRawClass()); JsonSerializer<?> ser = findSerializerFromAnnotation(config, beanDesc.getClassInfo()); if (ser == null) { // First, fast lookup for exact type: ser = findSerializerByLookup(type, config, beanDesc); if (ser == null) { /* and should that fail, slower introspection methods; first * one that deals with "primary" types */ ser = findSerializerByPrimaryType(type, config, beanDesc); if (ser == null) { // And if that fails, one with "secondary" traits: ser = findSerializerByAddonType(type, config, beanDesc); } } } return (JsonSerializer<Object>)ser; }
/** * Method called to construct a type serializer for values with given declared * base type. This is called for values other than those of bean property * types. */ @Override public TypeSerializer createTypeSerializer(JavaType baseType, SerializationConfig config) { BasicBeanDescription bean = config.introspectClassAnnotations(baseType.getRawClass()); AnnotatedClass ac = bean.getClassInfo(); AnnotationIntrospector ai = config.getAnnotationIntrospector(); TypeResolverBuilder<?> b = ai.findTypeResolver(ac, baseType); /* Ok: if there is no explicit type info handler, we may want to * use a default. If so, config object knows what to use. */ Collection<NamedType> subtypes = null; if (b == null) { b = config.getDefaultTyper(baseType); } else { subtypes = SubTypeHelper.collectAndResolveSubtypes(ac, config, ai); } return (b == null) ? null : b.buildTypeSerializer(baseType, subtypes); }
/** * Fast lookup-based accessor method, which will only check for * type itself, but not consider super-classes or implemented * interfaces. */ public final JsonSerializer<?> findSerializerByLookup(JavaType type, SerializationConfig config, BasicBeanDescription beanDesc) { JsonSerializer<?> ser = _concrete.get(type.getRawClass().getName()); /* 08-Nov-2009, tatus: Some standard types may need customization; * for now that just means Maps, but in future probably other * collections as well. For strictly standard types this is * currently only needed due to mix-in annotations. */ if (ser != null ) { if (ser == MapSerializer.instance) { return buildMapSerializer(type, config, beanDesc); } if (ser == ArraySerializers.ObjectArraySerializer.instance) { return buildObjectArraySerializer(type, config, beanDesc); } if (ser == ContainerSerializers.IndexedListSerializer.instance) { return buildIndexedListSerializer(type, config, beanDesc); } if (ser == ContainerSerializers.CollectionSerializer.instance) { return buildCollectionSerializer(type, config, beanDesc); } } return ser; }
protected SettableBeanProperty constructSettableProperty(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription, String paramString, AnnotatedField paramAnnotatedField) { if (paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) paramAnnotatedField.fixAccess(); JavaType localJavaType1 = paramBasicBeanDescription.bindingsForBeanType().resolveType(paramAnnotatedField.getGenericType()); BeanProperty.Std localStd = new BeanProperty.Std(paramString, localJavaType1, paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedField); JavaType localJavaType2 = resolveType(paramDeserializationConfig, paramBasicBeanDescription, localJavaType1, paramAnnotatedField, localStd); if (localJavaType2 != localJavaType1) localStd = localStd.withType(localJavaType2); JsonDeserializer localJsonDeserializer = findDeserializerFromAnnotation(paramDeserializationConfig, paramAnnotatedField, localStd); JavaType localJavaType3 = modifyTypeByAnnotation(paramDeserializationConfig, paramAnnotatedField, localJavaType2, paramString); Object localObject = new SettableBeanProperty.FieldProperty(paramString, localJavaType3, (TypeDeserializer)localJavaType3.getTypeHandler(), paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedField); if (localJsonDeserializer != null) localObject = ((SettableBeanProperty)localObject).withValueDeserializer(localJsonDeserializer); AnnotationIntrospector.ReferenceProperty localReferenceProperty = paramDeserializationConfig.getAnnotationIntrospector().findReferenceType(paramAnnotatedField); if ((localReferenceProperty != null) && (localReferenceProperty.isManagedReference())) ((SettableBeanProperty)localObject).setManagedReferenceName(localReferenceProperty.getName()); return localObject; }
/** * 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: type = modifyTypeByAnnotation(config, param, type, name); TypeDeserializer typeDeser = findTypeDeserializer(config, type); SettableBeanProperty prop = new SettableBeanProperty.CreatorProperty(name, type, typeDeser, beanDesc.getBeanClass(), index); if (deser != null) { prop.setValueDeserializer(deser); } return prop; }
public void setupModule(SetupContext context) { context.addBeanSerializerModifier(new BeanSerializerModifier() { @Override public List<BeanPropertyWriter> changeProperties(SerializationConfig config, BasicBeanDescription beanDesc, List<BeanPropertyWriter> beanProperties) { ListIterator<BeanPropertyWriter> it = beanProperties.listIterator(); while (it.hasNext()) { BeanPropertyWriter writer = it.next(); // replace the bean writer with my own if it is for "failed" if (writer.getName().equals("failed")) { BeanPropertyWriter newWriter = new IsFailedWriter(writer); it.set(newWriter); } } return beanProperties; } }); }
protected ValueInstantiator constructDefaultValueInstantiator(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription) { boolean bool = paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS); CreatorCollector localCreatorCollector = new CreatorCollector(paramBasicBeanDescription, bool); AnnotationIntrospector localAnnotationIntrospector = paramDeserializationConfig.getAnnotationIntrospector(); if (paramBasicBeanDescription.getType().isConcrete()) { AnnotatedConstructor localAnnotatedConstructor = paramBasicBeanDescription.findDefaultConstructor(); if (localAnnotatedConstructor != null) { if (bool) ClassUtil.checkAndFixAccess(localAnnotatedConstructor.getAnnotated()); localCreatorCollector.setDefaultConstructor(localAnnotatedConstructor); } } VisibilityChecker localVisibilityChecker1 = paramDeserializationConfig.getDefaultVisibilityChecker(); VisibilityChecker localVisibilityChecker2 = paramDeserializationConfig.getAnnotationIntrospector().findAutoDetectVisibility(paramBasicBeanDescription.getClassInfo(), localVisibilityChecker1); _addDeserializerFactoryMethods(paramDeserializationConfig, paramBasicBeanDescription, localVisibilityChecker2, localAnnotationIntrospector, localCreatorCollector); _addDeserializerConstructors(paramDeserializationConfig, paramBasicBeanDescription, localVisibilityChecker2, localAnnotationIntrospector, localCreatorCollector); return localCreatorCollector.constructValueInstantiator(paramDeserializationConfig); }
protected CreatorProperty constructCreatorProperty(DeserializationConfig paramDeserializationConfig, BasicBeanDescription paramBasicBeanDescription, String paramString, int paramInt, AnnotatedParameter paramAnnotatedParameter, Object paramObject) { JavaType localJavaType1 = paramDeserializationConfig.getTypeFactory().constructType(paramAnnotatedParameter.getParameterType(), paramBasicBeanDescription.bindingsForBeanType()); BeanProperty.Std localStd = new BeanProperty.Std(paramString, localJavaType1, paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedParameter); JavaType localJavaType2 = resolveType(paramDeserializationConfig, paramBasicBeanDescription, localJavaType1, paramAnnotatedParameter, localStd); if (localJavaType2 != localJavaType1) localStd = localStd.withType(localJavaType2); JsonDeserializer localJsonDeserializer = findDeserializerFromAnnotation(paramDeserializationConfig, paramAnnotatedParameter, localStd); JavaType localJavaType3 = modifyTypeByAnnotation(paramDeserializationConfig, paramAnnotatedParameter, localJavaType2, paramString); TypeDeserializer localTypeDeserializer1 = (TypeDeserializer)localJavaType3.getTypeHandler(); if (localTypeDeserializer1 == null); for (TypeDeserializer localTypeDeserializer2 = findTypeDeserializer(paramDeserializationConfig, localJavaType3, localStd); ; localTypeDeserializer2 = localTypeDeserializer1) { CreatorProperty localCreatorProperty = new CreatorProperty(paramString, localJavaType3, localTypeDeserializer2, paramBasicBeanDescription.getClassAnnotations(), paramAnnotatedParameter, paramInt, paramObject); if (localJsonDeserializer != null) localCreatorProperty = localCreatorProperty.withValueDeserializer(localJsonDeserializer); return localCreatorProperty; } }
public static KeyDeserializer findStringBasedKeyDeserializer(DeserializationConfig paramDeserializationConfig, JavaType paramJavaType) { BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspect(paramJavaType); Constructor localConstructor = localBasicBeanDescription.findSingleArgConstructor(new Class[] { String.class }); if (localConstructor != null) { if (paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) ClassUtil.checkAndFixAccess(localConstructor); return new StdKeyDeserializer.StringCtorKeyDeserializer(localConstructor); } Method localMethod = localBasicBeanDescription.findFactoryMethod(new Class[] { String.class }); if (localMethod != null) { if (paramDeserializationConfig.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) ClassUtil.checkAndFixAccess(localMethod); return new StdKeyDeserializer.StringFactoryKeyDeserializer(localMethod); } return null; }
public JsonDeserializer<?> createMapLikeDeserializer(DeserializationConfig paramDeserializationConfig, DeserializerProvider paramDeserializerProvider, MapLikeType paramMapLikeType, BeanProperty paramBeanProperty) { MapLikeType localMapLikeType1 = (MapLikeType)mapAbstractType(paramDeserializationConfig, paramMapLikeType); BasicBeanDescription localBasicBeanDescription = (BasicBeanDescription)paramDeserializationConfig.introspectForCreation(localMapLikeType1); JsonDeserializer localJsonDeserializer1 = findDeserializerFromAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), paramBeanProperty); if (localJsonDeserializer1 != null) return localJsonDeserializer1; MapLikeType localMapLikeType2 = (MapLikeType)modifyTypeByAnnotation(paramDeserializationConfig, localBasicBeanDescription.getClassInfo(), localMapLikeType1, null); JavaType localJavaType1 = localMapLikeType2.getKeyType(); JavaType localJavaType2 = localMapLikeType2.getContentType(); JsonDeserializer localJsonDeserializer2 = (JsonDeserializer)localJavaType2.getValueHandler(); KeyDeserializer localKeyDeserializer1 = (KeyDeserializer)localJavaType1.getValueHandler(); if (localKeyDeserializer1 == null); for (KeyDeserializer localKeyDeserializer2 = paramDeserializerProvider.findKeyDeserializer(paramDeserializationConfig, localJavaType1, paramBeanProperty); ; localKeyDeserializer2 = localKeyDeserializer1) { TypeDeserializer localTypeDeserializer1 = (TypeDeserializer)localJavaType2.getTypeHandler(); if (localTypeDeserializer1 == null); for (TypeDeserializer localTypeDeserializer2 = findTypeDeserializer(paramDeserializationConfig, localJavaType2, paramBeanProperty); ; localTypeDeserializer2 = localTypeDeserializer1) return _findCustomMapLikeDeserializer(localMapLikeType2, paramDeserializationConfig, paramDeserializerProvider, localBasicBeanDescription, paramBeanProperty, localKeyDeserializer2, localTypeDeserializer2, localJsonDeserializer2); } }