// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: braces fieldsfirst space lnc package com.fasterxml.jackson.databind.introspect; import com.fasterxml.jackson.databind.AnnotationIntrospector; import com.fasterxml.jackson.databind.BeanDescription; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.PropertyName; import com.fasterxml.jackson.databind.cfg.HandlerInstantiator; import com.fasterxml.jackson.databind.cfg.MapperConfig; import com.fasterxml.jackson.databind.type.TypeBindings; import com.fasterxml.jackson.databind.util.Annotations; import com.fasterxml.jackson.databind.util.ClassUtil; import com.fasterxml.jackson.databind.util.Converter; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; // Referenced classes of package com.fasterxml.jackson.databind.introspect: // POJOPropertiesCollector, BeanPropertyDefinition, AnnotatedMember, AnnotatedMethod, // AnnotatedWithParams, AnnotatedClass, AnnotatedConstructor, ObjectIdInfo, // AnnotatedParameter public class BasicBeanDescription extends BeanDescription { protected final AnnotationIntrospector _annotationIntrospector; protected TypeBindings _bindings; protected final AnnotatedClass _classInfo; protected final MapperConfig _config; protected ObjectIdInfo _objectIdInfo; protected final POJOPropertiesCollector _propCollector; protected List _properties; protected BasicBeanDescription(MapperConfig mapperconfig, JavaType javatype, AnnotatedClass annotatedclass, List list) { Object obj = null; super(javatype); _propCollector = null; _config = mapperconfig; if (_config == null) { mapperconfig = obj; } else { mapperconfig = _config.getAnnotationIntrospector(); } _annotationIntrospector = mapperconfig; _classInfo = annotatedclass; _properties = list; } protected BasicBeanDescription(POJOPropertiesCollector pojopropertiescollector) { this(pojopropertiescollector, pojopropertiescollector.getType(), pojopropertiescollector.getClassDef()); _objectIdInfo = pojopropertiescollector.getObjectIdInfo(); } protected BasicBeanDescription(POJOPropertiesCollector pojopropertiescollector, JavaType javatype, AnnotatedClass annotatedclass) { super(javatype); _propCollector = pojopropertiescollector; _config = pojopropertiescollector.getConfig(); if (_config == null) { pojopropertiescollector = null; } else { pojopropertiescollector = _config.getAnnotationIntrospector(); } _annotationIntrospector = pojopropertiescollector; _classInfo = annotatedclass; } public static BasicBeanDescription forDeserialization(POJOPropertiesCollector pojopropertiescollector) { return new BasicBeanDescription(pojopropertiescollector); } public static BasicBeanDescription forOtherUse(MapperConfig mapperconfig, JavaType javatype, AnnotatedClass annotatedclass) { return new BasicBeanDescription(mapperconfig, javatype, annotatedclass, Collections.emptyList()); } public static BasicBeanDescription forSerialization(POJOPropertiesCollector pojopropertiescollector) { return new BasicBeanDescription(pojopropertiescollector); } public Converter _createConverter(Object obj) { Object obj1 = null; if (obj == null) { return null; } if (obj instanceof Converter) { return (Converter)obj; } if (!(obj instanceof Class)) { throw new IllegalStateException((new StringBuilder()).append("AnnotationIntrospector returned Converter definition of type ").append(obj.getClass().getName()).append("; expected type Converter or Class instead").toString()); } Class class1 = (Class)obj; if (class1 == com/fasterxml/jackson/databind/util/Converter$None || ClassUtil.isBogusClass(class1)) { return null; } if (!com/fasterxml/jackson/databind/util/Converter.isAssignableFrom(class1)) { throw new IllegalStateException((new StringBuilder()).append("AnnotationIntrospector returned Class ").append(class1.getName()).append("; expected Class").toString()); } obj = _config.getHandlerInstantiator(); if (obj == null) { obj = obj1; } else { obj = ((HandlerInstantiator) (obj)).converterInstance(_config, _classInfo, class1); } obj1 = obj; if (obj == null) { obj1 = (Converter)ClassUtil.createInstance(class1, _config.canOverrideAccessModifiers()); } return ((Converter) (obj1)); } protected PropertyName _findCreatorPropertyName(AnnotatedParameter annotatedparameter) { PropertyName propertyname; label0: { PropertyName propertyname1 = _annotationIntrospector.findNameForDeserialization(annotatedparameter); if (propertyname1 != null) { propertyname = propertyname1; if (!propertyname1.isEmpty()) { break label0; } } annotatedparameter = _annotationIntrospector.findImplicitPropertyName(annotatedparameter); propertyname = propertyname1; if (annotatedparameter != null) { propertyname = propertyname1; if (!annotatedparameter.isEmpty()) { propertyname = PropertyName.construct(annotatedparameter); } } } return propertyname; } public LinkedHashMap _findPropertyFields(Collection collection, boolean flag) { LinkedHashMap linkedhashmap = new LinkedHashMap(); Iterator iterator = _properties().iterator(); do { if (!iterator.hasNext()) { break; } Object obj = (BeanPropertyDefinition)iterator.next(); AnnotatedField annotatedfield = ((BeanPropertyDefinition) (obj)).getField(); if (annotatedfield != null) { obj = ((BeanPropertyDefinition) (obj)).getName(); if (collection == null || !collection.contains(obj)) { linkedhashmap.put(obj, annotatedfield); } } } while (true); return linkedhashmap; } protected List _properties() { if (_properties == null) { _properties = _propCollector.getProperties(); } return _properties; } public boolean addProperty(BeanPropertyDefinition beanpropertydefinition) { if (hasProperty(beanpropertydefinition.getFullName())) { return false; } else { _properties().add(beanpropertydefinition); return true; } } public TypeBindings bindingsForBeanType() { if (_bindings == null) { _bindings = new TypeBindings(_config.getTypeFactory(), _type); } return _bindings; } public AnnotatedMember findAnyGetter() throws IllegalArgumentException { AnnotatedMember annotatedmember; if (_propCollector == null) { annotatedmember = null; } else { annotatedmember = _propCollector.getAnyGetter(); } if (annotatedmember != null && !java/util/Map.isAssignableFrom(annotatedmember.getRawType())) { throw new IllegalArgumentException((new StringBuilder()).append("Invalid 'any-getter' annotation on method ").append(annotatedmember.getName()).append("(): return type is not instance of java.util.Map").toString()); } else { return annotatedmember; } } public AnnotatedMethod findAnySetter() throws IllegalArgumentException { AnnotatedMethod annotatedmethod; if (_propCollector == null) { annotatedmethod = null; } else { annotatedmethod = _propCollector.getAnySetterMethod(); } if (annotatedmethod != null) { Class class1 = annotatedmethod.getRawParameterType(0); if (class1 != java/lang/String && class1 != java/lang/Object) { throw new IllegalArgumentException((new StringBuilder()).append("Invalid 'any-setter' annotation on method ").append(annotatedmethod.getName()).append("(): first argument not of type String or Object, but ").append(class1.getName()).toString()); } } return annotatedmethod; } public Map findBackReferenceProperties() { HashMap hashmap = null; for (Iterator iterator = _properties().iterator(); iterator.hasNext();) { AnnotatedMember annotatedmember = ((BeanPropertyDefinition)iterator.next()).getMutator(); if (annotatedmember != null) { Object obj = _annotationIntrospector.findReferenceType(annotatedmember); if (obj != null && ((com.fasterxml.jackson.databind.AnnotationIntrospector.ReferenceProperty) (obj)).isBackReference()) { HashMap hashmap1 = hashmap; if (hashmap == null) { hashmap1 = new HashMap(); } obj = ((com.fasterxml.jackson.databind.AnnotationIntrospector.ReferenceProperty) (obj)).getName(); hashmap = hashmap1; if (hashmap1.put(obj, annotatedmember) != null) { throw new IllegalArgumentException((new StringBuilder()).append("Multiple back-reference properties with name '").append(((String) (obj))).append("'").toString()); } } } } return hashmap; } public List findCreatorParameterNames() { Object obj; label0: { int i = 0; do { if (i >= 2) { break; } Iterator iterator; if (i == 0) { obj = getConstructors(); } else { obj = getFactoryMethods(); } for (iterator = ((List) (obj)).iterator(); iterator.hasNext();) { AnnotatedWithParams annotatedwithparams = (AnnotatedWithParams)iterator.next(); int j = annotatedwithparams.getParameterCount(); if (j >= 1) { obj = _findCreatorPropertyName(annotatedwithparams.getParameter(0)); if (obj != null && !((PropertyName) (obj)).isEmpty()) { ArrayList arraylist = new ArrayList(); arraylist.add(obj); i = 1; do { obj = arraylist; if (i >= j) { break; } arraylist.add(_findCreatorPropertyName(annotatedwithparams.getParameter(i))); i++; } while (true); break label0; } } } i++; } while (true); obj = Collections.emptyList(); } return ((List) (obj)); } public List findCreatorPropertyNames() { Object obj = findCreatorParameterNames(); if (!((List) (obj)).isEmpty()) goto _L2; else goto _L1 _L1: obj = Collections.emptyList(); _L4: return ((List) (obj)); _L2: ArrayList arraylist = new ArrayList(((List) (obj)).size()); Iterator iterator = ((List) (obj)).iterator(); do { obj = arraylist; if (!iterator.hasNext()) { continue; } arraylist.add(((PropertyName)iterator.next()).getSimpleName()); } while (true); if (true) goto _L4; else goto _L3 _L3: } public AnnotatedConstructor findDefaultConstructor() { return _classInfo.getDefaultConstructor(); } public Converter findDeserializationConverter() { if (_annotationIntrospector == null) { return null; } else { return _createConverter(_annotationIntrospector.findDeserializationConverter(_classInfo)); } } public com.fasterxml.jackson.annotation.JsonFormat.Value findExpectedFormat(com.fasterxml.jackson.annotation.JsonFormat.Value value) { if (_annotationIntrospector != null) { com.fasterxml.jackson.annotation.JsonFormat.Value value1 = _annotationIntrospector.findFormat(_classInfo); if (value1 != null) { return value1; } } return value; } public transient Method findFactoryMethod(Class aclass[]) { Iterator iterator = _classInfo.getStaticMethods().iterator(); do { if (!iterator.hasNext()) { break; } AnnotatedMethod annotatedmethod = (AnnotatedMethod)iterator.next(); if (isFactoryMethod(annotatedmethod)) { Class class1 = annotatedmethod.getRawParameterType(0); int j = aclass.length; int i = 0; while (i < j) { if (class1.isAssignableFrom(aclass[i])) { return annotatedmethod.getAnnotated(); } i++; } } } while (true); return null; } public Map findInjectables() { if (_propCollector != null) { return _propCollector.getInjectables(); } else { return Collections.emptyMap(); } } public AnnotatedMethod findJsonValueMethod() { if (_propCollector == null) { return null; } else { return _propCollector.getJsonValueMethod(); } } public AnnotatedMethod findMethod(String s, Class aclass[]) { return _classInfo.findMethod(s, aclass); } public Class findPOJOBuilder() { if (_annotationIntrospector == null) { return null; } else { return _annotationIntrospector.findPOJOBuilder(_classInfo); } } public com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder.Value findPOJOBuilderConfig() { if (_annotationIntrospector == null) { return null; } else { return _annotationIntrospector.findPOJOBuilderConfig(_classInfo); } } public List findProperties() { return _properties(); } public BeanPropertyDefinition findProperty(PropertyName propertyname) { for (Iterator iterator = _properties().iterator(); iterator.hasNext();) { BeanPropertyDefinition beanpropertydefinition = (BeanPropertyDefinition)iterator.next(); if (beanpropertydefinition.hasName(propertyname)) { return beanpropertydefinition; } } return null; } public Converter findSerializationConverter() { if (_annotationIntrospector == null) { return null; } else { return _createConverter(_annotationIntrospector.findSerializationConverter(_classInfo)); } } public com.fasterxml.jackson.annotation.JsonInclude.Include findSerializationInclusion(com.fasterxml.jackson.annotation.JsonInclude.Include include) { if (_annotationIntrospector == null) { return include; } else { return _annotationIntrospector.findSerializationInclusion(_classInfo, include); } } public com.fasterxml.jackson.annotation.JsonInclude.Include findSerializationInclusionForContent(com.fasterxml.jackson.annotation.JsonInclude.Include include) { if (_annotationIntrospector == null) { return include; } else { return _annotationIntrospector.findSerializationInclusionForContent(_classInfo, include); } } public transient Constructor findSingleArgConstructor(Class aclass[]) { Iterator iterator = _classInfo.getConstructors().iterator(); do { if (!iterator.hasNext()) { break; } AnnotatedConstructor annotatedconstructor = (AnnotatedConstructor)iterator.next(); if (annotatedconstructor.getParameterCount() == 1) { Class class1 = annotatedconstructor.getRawParameterType(0); int j = aclass.length; int i = 0; while (i < j) { if (aclass[i] == class1) { return annotatedconstructor.getAnnotated(); } i++; } } } while (true); return null; } public Annotations getClassAnnotations() { return _classInfo.getAnnotations(); } public AnnotatedClass getClassInfo() { return _classInfo; } public List getConstructors() { return _classInfo.getConstructors(); } public List getFactoryMethods() { Object obj = _classInfo.getStaticMethods(); if (((List) (obj)).isEmpty()) { return ((List) (obj)); } ArrayList arraylist = new ArrayList(); obj = ((List) (obj)).iterator(); do { if (!((Iterator) (obj)).hasNext()) { break; } AnnotatedMethod annotatedmethod = (AnnotatedMethod)((Iterator) (obj)).next(); if (isFactoryMethod(annotatedmethod)) { arraylist.add(annotatedmethod); } } while (true); return arraylist; } public Set getIgnoredPropertyNames() { Set set; Set set1; if (_propCollector == null) { set = null; } else { set = _propCollector.getIgnoredPropertyNames(); } set1 = set; if (set == null) { set1 = Collections.emptySet(); } return set1; } public ObjectIdInfo getObjectIdInfo() { return _objectIdInfo; } public boolean hasKnownClassAnnotations() { return _classInfo.hasAnnotations(); } public boolean hasProperty(PropertyName propertyname) { return findProperty(propertyname) != null; } public Object instantiateBean(boolean flag) { Object obj = _classInfo.getDefaultConstructor(); if (obj == null) { return null; } if (flag) { ((AnnotatedConstructor) (obj)).fixAccess(); } try { obj = ((AnnotatedConstructor) (obj)).getAnnotated().newInstance(new Object[0]); } catch (Object obj1) { for (; ((Throwable) (obj1)).getCause() != null; obj1 = ((Throwable) (obj1)).getCause()) { } if (obj1 instanceof Error) { throw (Error)obj1; } if (obj1 instanceof RuntimeException) { throw (RuntimeException)obj1; } else { throw new IllegalArgumentException((new StringBuilder()).append("Failed to instantiate bean of type ").append(_classInfo.getAnnotated().getName()).append(": (").append(obj1.getClass().getName()).append(") ").append(((Throwable) (obj1)).getMessage()).toString(), ((Throwable) (obj1))); } } return obj; } protected boolean isFactoryMethod(AnnotatedMethod annotatedmethod) { Class class1 = annotatedmethod.getRawReturnType(); if (getBeanClass().isAssignableFrom(class1)) { if (_annotationIntrospector.hasCreatorAnnotation(annotatedmethod)) { return true; } String s = annotatedmethod.getName(); if ("valueOf".equals(s)) { return true; } if ("fromString".equals(s) && 1 == annotatedmethod.getParameterCount()) { annotatedmethod = annotatedmethod.getRawParameterType(0); if (annotatedmethod == java/lang/String || java/lang/CharSequence.isAssignableFrom(annotatedmethod)) { return true; } } } return false; } public boolean removeProperty(String s) { for (Iterator iterator = _properties().iterator(); iterator.hasNext();) { if (((BeanPropertyDefinition)iterator.next()).getName().equals(s)) { iterator.remove(); return true; } } return false; } public JavaType resolveType(Type type) { if (type == null) { return null; } else { return bindingsForBeanType().resolveType(type); } } }