Generated by
JDiff

com.google.inject.testing.fieldbinder Documentation Differences

This file contains all the changes in documentation in the package com.google.inject.testing.fieldbinder as colored differences. Deletions are shown like this, and additions are shown like this.
If no deletions or additions are shown in an entry, the HTML tags will be what has changed. The new HTML tags are shown in the differences. If no documentation existed, and then some was added in a later version, this change is noted in the appropriate class pages of differences, but the change is not shown on this page. Only changes in existing text are shown here. Similarly, documentation which was inherited from another class or interface is not shown here.
Note that an HTML error in the new documentation may cause the display of other documentation changes to be presented incorrectly. For instance, failure to close a <code> tag will cause all subsequent paragraphs to be displayed differently.

Class Bind

Annotation used by BoundFieldModule to indicate that a field should be bound to its valueits value using Guice.

Binding to {@code null} is only allowed for fields that are annotated {@code @Nullable}. See https://github.com/google/guice/wiki/UseNullable @see BoundFieldModule @author eatnumber1@google.com (Russ Harmon)


Class BoundFieldModule

Automatically creates Guice bindings for fields in an object annotated with Bind.

This module is intended for use in tests to reduce the code needed to bind local fields (usually mocks) for injection.

The following rules are followed in determining how fields are bound using this module:

Example use:


 public class TestFoo {
   // bind(new TypeLiteral{@code >}() {}).toInstance(listOfObjects);
   {@literal @}Bind private List{@code } listOfObjects = Lists.of();

   // private String userName = "string_that_changes_over_time";
   // bind(String.class).toProvider(new Provider() { public String get() { return userName; }});
   {@literal @}Bind(lazy = true) private String userName;

   // bind(SuperClass.class).toInstance(aSubClass);
   {@literal @}Bind(to = SuperClass.class) private SubClass aSubClass = new SubClass();

   // bind(String.class).annotatedWith(MyBindingAnnotation.class).toInstance(myString);
   {@literal @}Bind
   {@literal @}MyBindingAnnotation
   private String myString = "hello";

   // bind(Object.class).toProvider(myProvider);
   {@literal @}Bind private Provider{@code } myProvider = getProvider();

   {@literal @}Before public void setUp() {
     Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
   }
 }
 

 @see Bind
 @author eatnumber1@google.com (Russ Harmon)