Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.jackson.databind.introspect;
  
 
 public class BasicClassIntrospector
     extends ClassIntrospector
     implements java.io.Serializable
 {
     private static final long serialVersionUID = 1L;
 
     /* We keep a small set of pre-constructed descriptions to use for
      * common non-structured values, such as Numbers and Strings.
      * This is strictly performance optimization to reduce what is
      * usually one-time cost, but seems useful for some cases considering
      * simplicity.
      */
     
     protected final static BasicBeanDescription STRING_DESC;
     static {
         AnnotatedClass ac = AnnotatedClass.constructWithoutSuperTypes(String.classnullnull);
          = BasicBeanDescription.forOtherUse(null, SimpleType.constructUnsafe(String.class), ac);
     }
     protected final static BasicBeanDescription BOOLEAN_DESC;
     static {
         AnnotatedClass ac = AnnotatedClass.constructWithoutSuperTypes(.nullnull);
          = BasicBeanDescription.forOtherUse(null, SimpleType.constructUnsafe(.), ac);
     }
     protected final static BasicBeanDescription INT_DESC;
     static {
         AnnotatedClass ac = AnnotatedClass.constructWithoutSuperTypes(.nullnull);
          = BasicBeanDescription.forOtherUse(null, SimpleType.constructUnsafe(.), ac);
     }
     protected final static BasicBeanDescription LONG_DESC;
     static {
         AnnotatedClass ac = AnnotatedClass.constructWithoutSuperTypes(.nullnull);
          = BasicBeanDescription.forOtherUse(null, SimpleType.constructUnsafe(.), ac);
     }
     
     /*
     /**********************************************************
     /* Life cycle
     /**********************************************************
      */
 
     public final static BasicClassIntrospector instance = new BasicClassIntrospector();
 
     public BasicClassIntrospector() { }
     
     /*
     /**********************************************************
     /* Factory method impls
     /**********************************************************
      */
 
     @Override
             JavaType typeMixInResolver r)
     {
         // minor optimization: for JDK types do minimal introspection
         BasicBeanDescription desc = _findCachedDesc(type);
         if (desc == null) {
             desc = BasicBeanDescription.forSerialization(collectProperties(cfg,
             		typertrue"set"));
         }
         return desc;
     }
 
     @Override
             JavaType typeMixInResolver r)
     {
         // minor optimization: for JDK types do minimal introspection
         BasicBeanDescription desc = _findCachedDesc(type);
         if (desc == null) {
             desc = BasicBeanDescription.forDeserialization(collectProperties(cfg,
             		typerfalse"set"));
         }
         return desc;
     }
 
     @Override
             JavaType typeMixInResolver r)
     {
     	// no caching for Builders (no standard JDK builder types):
     	return BasicBeanDescription.forDeserialization(collectPropertiesWithBuilder(cfg,
             		typerfalse));
     }
     
     @Override
             JavaType typeMixInResolver r)
     {
        BasicBeanDescription desc = _findCachedDesc(type);
        if (desc == null) {
            desc = BasicBeanDescription.forDeserialization(
            		collectProperties(cfgtyperfalse"set"));
        }
        return desc;
    }
    @Override
            JavaType typeMixInResolver r)
    {
        boolean useAnnotations = cfg.isAnnotationProcessingEnabled();
        AnnotatedClass ac = AnnotatedClass.construct(type.getRawClass(),
                (useAnnotations ? cfg.getAnnotationIntrospector() : null), r);
        return BasicBeanDescription.forOtherUse(cfgtypeac);
    }
    @Override
            JavaType typeMixInResolver r)
    {
        boolean useAnnotations = cfg.isAnnotationProcessingEnabled();
        AnnotationIntrospector ai =  cfg.getAnnotationIntrospector();
        AnnotatedClass ac = AnnotatedClass.constructWithoutSuperTypes(type.getRawClass(),
                (useAnnotations ? ai : null), r);
        return BasicBeanDescription.forOtherUse(cfgtypeac);
    }
    
    /*
    /**********************************************************
    /* Overridable helper methods
    /**********************************************************
     */
            JavaType typeMixInResolver rboolean forSerialization,
            String mutatorPrefix)
    {
        boolean useAnnotations = config.isAnnotationProcessingEnabled();
        AnnotatedClass ac = AnnotatedClass.construct(type.getRawClass(),
                (useAnnotations ? config.getAnnotationIntrospector() : null), r);
        return constructPropertyCollector(configactypeforSerializationmutatorPrefix).collect();
    }
    
            JavaType typeMixInResolver rboolean forSerialization)
    {
        boolean useAnnotations = config.isAnnotationProcessingEnabled();
        AnnotationIntrospector ai = useAnnotations ? config.getAnnotationIntrospector() : null;
        AnnotatedClass ac = AnnotatedClass.construct(type.getRawClass(), air);
        JsonPOJOBuilder.Value builderConfig = (ai == null) ? null : ai.findPOJOBuilderConfig(ac);
        String mutatorPrefix = (builderConfig == null) ? "with" : builderConfig.withPrefix;
        return constructPropertyCollector(configactypeforSerializationmutatorPrefix).collect();
    }

    
Overridable method called for creating POJOPropertiesCollector instance to use; override is needed if a custom sub-class is to be used.
            AnnotatedClass acJavaType type,
            boolean forSerializationString mutatorPrefix)
    {
        return new POJOPropertiesCollector(configforSerializationtypeacmutatorPrefix);
    }
    
    
Method called to see if type is one of core JDK types that we have cached for efficiency.
    {
        Class<?> cls = type.getRawClass();
        if (cls == String.class) {
            return ;
        }
        if (cls == .) {
            return ;
        }
        if (cls == .) {
            return ;
        }
        if (cls == .) {
            return ;
        }
        return null;
    }
New to GrepCode? Check out our FAQ X