Annotation Type ProvidesIntoOptional


@Documented @Target(METHOD) @Retention(RUNTIME) public @interface ProvidesIntoOptional
Annotates methods of a Module to add items to a Multibinder. The method's return type and binding annotation determines what Optional this will contribute to. For example,
 @ProvidesIntoOptional(DEFAULT)
 @Named("url")
 String provideFooUrl(FooManager fm) { returm fm.getUrl(); }

 @ProvidesIntoOptional(ACTUAL)
 @Named("url")
 String provideBarUrl(BarManager bm) { return bm.getUrl(); }
 
will set the default value of @Named("url") Optional<String> to foo's URL, and then override it to bar's URL.
Since:
4.0
Author:
sameb@google.com (Sam Berlin)
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Specifies if the binding is for the actual or default value.