Mention in OptionalBinder that java.util.Optional and c.g.c.base.Opti… · google/guice@2f7afd6 (original) (raw)

File tree

Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@
18 18
19 19 import static com.google.inject.internal.RealOptionalBinder.newRealOptionalBinder;
20 20
21 -import com.google.common.base.Optional;
22 21 import com.google.inject.Binder;
23 22 import com.google.inject.Key;
24 23 import com.google.inject.TypeLiteral;
@@ -35,8 +34,9 @@
35 34 *
36 35 *
37 36 *

When an OptionalBinder is added, it will always supply the bindings: {@code Optional} and

38 - * {@code Optional<Provider>}. If {@link #setBinding} or {@link #setDefault} are called, it will
39 - * also bind {@code T}.
37 + * {@code Optional<Provider>}. Both {@link java.util.Optional java.util.Optional} and {@link
38 + * com.google.common.base.Optional com.google.common.base.Optional} are bound for compatibility. If
39 + * {@link #setBinding} or {@link #setDefault} are called, it will also bind {@code T}.
40 40 *
41 41 *

{@code setDefault} is intended for use by frameworks that need a default value. User code can

42 42 * call {@code setBinding} to override the default. Warning: Even if setBinding is called, the
@@ -66,8 +66,8 @@
66 66 * }
67 67 * }
68 68 *
69 - *

With this module, an {@link Optional}{@code } can now be injected. With no other

70 - * bindings, the optional will be absent. Users can specify bindings in one of two ways:
69 + *

With this module, an {@code Optional} can now be injected. With no other bindings,

70 + * the optional will be absent. Users can specify bindings in one of two ways:
71 71 *
72 72 *

Option 1:

73 73 *