private Mapper createMapper ( Field field , boolean indexed ) { lock . lock ( ) ; try { Mapper mapper ; Class < ? > fieldType = field . getType ( ) ; Type genericType = field . getGenericType ( ) ; String cacheKey = computeCacheKey ( genericType , indexed ) ; mapper = cache . get ( cacheKey ) ; if ( mapper != null ) { return mapper ; } if ( List . class . isAssignableFrom ( fieldType ) ) { mapper = new ListMapper ( genericType , indexed ) ; } else if ( Set . class . isAssignableFrom ( fieldType ) ) { mapper = new SetMapper ( genericType , indexed ) ; } else { // we shouldn't be getting here throw new IllegalArgumentException ( String . format ( "Field type must be List or Set, found %s" , fieldType ) ) ; } cache . put ( cacheKey , mapper ) ; return mapper ; } finally { lock . unlock ( ) ; } }
Creates a new Mapper for the given field .