@ SuppressWarnings ( "unchecked" ) public static < T > T that ( Object key , Supplier < T > what ) { if ( CACHE . get ( key ) != null ) { try { return ( T ) CACHE . get ( key ) ; } catch ( ClassCastException e ) { System . out . print ( "E/Cache: Can't use cached object: wrong type" ) ; } } T value = what . get ( ) ; CACHE . put ( key , value ) ; return value ; }
Registers creator of item and returns item from cache or creator