Skip to content

Commit

Permalink
Clarify behavior of setBinding().
Browse files Browse the repository at this point in the history
Previous comment is ambiguous. It's unclear if OptionalBinder installs bindings or not:
<p>If setDefault or setBinding are linked to Providers, the Provider may return {@code null}. If it does, the Optional bindings will be absent.

In fact, bindings are installed (Optional<T> -> Optional.empty()).

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=194848832
  • Loading branch information
reddaly authored and ronshapiro committed May 1, 2018
1 parent c0f89a0 commit 2642dc4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/src/com/google/inject/multibindings/OptionalBinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
* roles:
*
* <ol>
* <li>It allows a framework to define an injection point that may or may not be bound by users.
* <li>It allows a framework to supply a default value that can be changed by users.
* <li>It allows a framework to define an injection point that may or may not be bound by users.
* <li>It allows a framework to supply a default value that can be changed by users.
* </ol>
*
* <p>When an OptionalBinder is added, it will always supply the bindings: {@code Optional<T>} and
Expand All @@ -44,8 +44,8 @@
* instantiated in {@code Stage.PRODUCTION}.</b>
*
* <p>If setDefault or setBinding are linked to Providers, the Provider may return {@code null}. If
* it does, the Optional bindings will be absent. Binding setBinding to a Provider that returns null
* will not cause OptionalBinder to fall back to the setDefault binding.
* it does, {@code Optional<T>} will be bound to an absent Optional. Binding setBinding to a
* Provider that returns null will not cause OptionalBinder to fall back to the setDefault binding.
*
* <p>If neither setDefault nor setBinding are called, it will try to link to a user-supplied
* binding of the same type. If no binding exists, the optionals will be absent. Otherwise, if a
Expand Down

0 comments on commit 2642dc4

Please sign in to comment.