@ SuppressWarnings ( "unchecked" ) @ Pure public static < T > Drawer < T > getDrawerFor ( Class < ? extends T > type ) { assert type != null : AssertMessages . notNullParameter ( ) ; final Drawer < ? > bufferedType = buffer . get ( type ) ; Drawer < T > defaultChoice = null ; if ( bufferedType != null ) { defaultChoice = ( Drawer < T > ) bufferedType ; } else { final Iterator < Drawer < ? > > iterator = getAllDrawers ( ) ; while ( iterator . hasNext ( ) ) { final Drawer < ? > drawer = iterator . next ( ) ; final Class < ? > drawerType = drawer . getPrimitiveType ( ) ; if ( drawerType . equals ( type ) ) { defaultChoice = ( Drawer < T > ) drawer ; break ; } else if ( drawerType . isAssignableFrom ( type ) && ( defaultChoice == null || drawerType . isAssignableFrom ( defaultChoice . getPrimitiveType ( ) ) ) ) { defaultChoice = ( Drawer < T > ) drawer ; } } if ( defaultChoice != null ) { buffer . put ( type , defaultChoice ) ; } } return defaultChoice ; }
Replies the first registered document drawer that is supporting the given type .