Hidden Features of Google Guice

Posted by Jon on Stack Overflow See other posts from Stack Overflow or by Jon
Published on 2010-04-26T21:22:29Z Indexed on 2010/04/27 0:03 UTC
Read the original article Hit count: 186

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?

© Stack Overflow or respective owner

Related posts about guice

Related posts about dependency-injection