Hidden Features of Google Guice
- by Jon
Google Guice provides some great dependency injection features.
I came across the @Nullable feature recently which allows you to mark constructor arguments as optional (permitting null) since Guice does not permit these by default:
e.g.
public Person(String firstName, String lastName, @Nullable Phone phone) {
this.firstName = checkNotNull(firstName, "firstName");
this.lastName = checkNotNull(lastName, "lastName");
this.phone = phone;
}
http://code.google.com/p/google-guice/wiki/UseNullable
What are the other useful features of Guice (particularly the less obvious ones) that people use?