Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.fasterxml.jackson.databind.util;
 
 
Helper class for caching resolved root names.
public class RootNameLookup
    implements java.io.Serializable
    private static final long serialVersionUID = 1L;

    
For efficient operation, let's try to minimize number of times we need to introspect root element name to use.
    protected transient LRUMap<ClassKey,SerializedString_rootNames;
    public RootNameLookup() { }
    public SerializedString findRootName(JavaType rootTypeMapperConfig<?> config)
    {
        return findRootName(rootType.getRawClass(), config);
    }
    public SerializedString findRootName(Class<?> rootTypeMapperConfig<?> config)
    {
        ClassKey key = new ClassKey(rootType);
        synchronized (this) {
            if ( == null) {
                 = new LRUMap<ClassKey,SerializedString>(20, 200);
            } else {
                SerializedString name = .get(key);
                if (name != null) {
                    return name;
                }
            }
        }
        BeanDescription beanDesc = config.introspectClassAnnotations(rootType);
        AnnotationIntrospector intr = config.getAnnotationIntrospector();
        AnnotatedClass ac = beanDesc.getClassInfo();
        PropertyName pname = intr.findRootName(ac);
        String nameStr;
        // No answer so far? Let's just default to using simple class name
        if (pname == null || !pname.hasSimpleName()) {
            // Should we strip out enclosing class tho? For now, nope:
            nameStr = rootType.getSimpleName();
        } else {
            nameStr = pname.getSimpleName();
        }
        SerializedString name = new SerializedString(nameStr);
        synchronized (this) {
            .put(keyname);
        }
        return name;
    }
New to GrepCode? Check out our FAQ X