EmptySetMultibindingContributions
@Multibinds is a more efficient and declarative mechanism for ensuring that a set multibinding is present in the graph.

Severity
SUGGESTION
Has Fix?
REQUIRES_HUMAN_ATTENTION

The problem

When using Dagger Multibinding, you can use methods like the below to make sure that there’s a (potentially empty) Set binding for your type:

@Provides @ElementsIntoSet Set<MyType> provideEmptySetOfMyType() {
  return new HashSet<>();
}

However, there’s a slightly easier way to express this:

@Multibinds abstract Set<?> provideEmptySetOfMyType();

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("EmptySetMultibindingContributions") to the enclosing element.