@ SuppressFBWarnings ( value = "GC_UNRELATED_TYPES" , justification = "Cross-comparison is intended" ) public Class < ? > insert ( ClassLoader classLoader , T key , Class < ? > type ) { ConcurrentMap < T , Reference < Class < ? > > > storage = cache . get ( new LookupKey ( classLoader ) ) ; if ( storage == null ) { storage = new ConcurrentHashMap < T , Reference < Class < ? > > > ( ) ; ConcurrentMap < T , Reference < Class < ? > > > previous = cache . putIfAbsent ( new StorageKey ( classLoader , this ) , storage ) ; if ( previous != null ) { storage = previous ; } } Reference < Class < ? > > reference = sort . wrap ( type ) , previous = storage . putIfAbsent ( key , reference ) ; while ( previous != null ) { Class < ? > previousType = previous . get ( ) ; if ( previousType != null ) { return previousType ; } else if ( storage . remove ( key , previous ) ) { previous = storage . putIfAbsent ( key , reference ) ; } else { previous = storage . get ( key ) ; if ( previous == null ) { previous = storage . putIfAbsent ( key , reference ) ; } } } return type ; }
Inserts a new type into the cache . If a type with the same class loader and key was inserted previously the cache is not updated .