protected Binding bindAnnotatedWithNameToInstance ( TypeReference bind , String name , String to , String functionName ) { String tmpName = Strings . emptyIfNull ( name ) ; if ( tmpName . startsWith ( REFERENCE_PREFIX ) ) { tmpName = tmpName . substring ( REFERENCE_PREFIX . length ( ) ) . trim ( ) ; } else { tmpName = "\"" + tmpName + "\"" ; //$NON-NLS-1$//$NON-NLS-2$ } final String unferencedName = tmpName ; final StringConcatenationClient client = new StringConcatenationClient ( ) { @ Override protected void appendTo ( TargetStringConcatenation builder ) { builder . append ( "binder.bind(" ) ; //$NON-NLS-1$ builder . append ( bind ) ; builder . append ( ".class).annotatedWith(Names.named(" ) ; //$NON-NLS-1$ builder . append ( unferencedName ) ; builder . append ( ")).toInstance(" ) ; //$NON-NLS-1$ builder . append ( to ) ; builder . append ( ".class);" ) ; //$NON-NLS-1$ } } ; String fctname = functionName ; if ( Strings . isEmpty ( fctname ) ) { fctname = name ; } final BindKey key = new GuiceModuleAccess . BindKey ( formatFunctionName ( fctname ) , null , false , false ) ; final BindValue statements = new BindValue ( null , null , false , Collections . singletonList ( client ) ) ; return new Binding ( key , statements , true , this . name ) ; }
Bind a type annotated with a name of the given value .