public < P1 , P2 > V putIfAbsentGetIfPresent ( K key , Function2 < K , V , K > keyTransformer , Function3 < P1 , P2 , K , V > factory , P1 param1 , P2 param2 ) { int hash = this . hash ( key ) ; Object [ ] currentArray = this . table ; V newValue = null ; boolean createdValue = false ; while ( true ) { int length = currentArray . length ; int index = ConcurrentHashMapUnsafe . indexFor ( hash , length ) ; Object o = ConcurrentHashMapUnsafe . arrayAt ( currentArray , index ) ; if ( o == RESIZED || o == RESIZING ) { currentArray = this . helpWithResizeWhileCurrentIndex ( currentArray , index ) ; } else { Entry < K , V > e = ( Entry < K , V > ) o ; while ( e != null ) { Object candidate = e . getKey ( ) ; if ( candidate . equals ( key ) ) { return e . getValue ( ) ; } e = e . getNext ( ) ; } if ( ! createdValue ) { createdValue = true ; newValue = factory . value ( param1 , param2 , key ) ; if ( newValue == null ) { return null ; // null value means no mapping is required } key = keyTransformer . value ( key , newValue ) ; } Entry < K , V > newEntry = new Entry < K , V > ( key , newValue , ( Entry < K , V > ) o ) ; if ( ConcurrentHashMapUnsafe . casArrayAt ( currentArray , index , o , newEntry ) ) { this . incrementSizeAndPossiblyResize ( currentArray , length , o ) ; return null ; } } } }
It puts an object into the map based on the key . It uses a copy of the key converted by transformer .