Skip to content

Commit 2c088d7

Browse files
vkryachkorlazo
andauthored
Mark Dependency.optional as deprecated. (#2334)
* Mark Dependency.optional as deprecated. * Apply suggestions from code review Co-authored-by: Rodrigo Lazo <[email protected]> Co-authored-by: Rodrigo Lazo <[email protected]>
1 parent 6ccc9de commit 2c088d7

File tree

1 file changed

+52
-0
lines changed
  • firebase-components/src/main/java/com/google/firebase/components

1 file changed

+52
-0
lines changed

firebase-components/src/main/java/com/google/firebase/components/Dependency.java

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,30 +47,82 @@ private Dependency(Class<?> anInterface, @Type int type, @Injection int injectio
4747
this.injection = injection;
4848
}
4949

50+
/**
51+
* Declares an optional dependency.
52+
*
53+
* <p>Optional dependencies can be missing at runtime(being {@code null}) and dependents must be
54+
* ready to handle that.
55+
*
56+
* @deprecated Optional dependencies are not safe to use in the context of Play's dynamic feature
57+
* delivery. Use {@link #optionalProvider(Class) optional provider} instead.
58+
*/
59+
@Deprecated
5060
public static Dependency optional(Class<?> anInterface) {
5161
return new Dependency(anInterface, Type.OPTIONAL, Injection.DIRECT);
5262
}
5363

64+
/**
65+
* Declares a deferred dependency.
66+
*
67+
* <p>Such dependencies are optional and may not be present by default. But they can become
68+
* available if a dynamic module that contains them is installed.
69+
*/
5470
public static Dependency deferred(Class<?> anInterface) {
5571
return new Dependency(anInterface, Type.OPTIONAL, Injection.DEFERRED);
5672
}
5773

74+
/**
75+
* Declares a required dependency.
76+
*
77+
* <p>Such dependencies must be present in order for the dependent component to function. Any
78+
* component with a required dependency should also declare a Maven dependency on an SDK that
79+
* provides it. Failing to do so will result in a {@link MissingDependencyException} to be thrown
80+
* at runtime.
81+
*/
5882
public static Dependency required(Class<?> anInterface) {
5983
return new Dependency(anInterface, Type.REQUIRED, Injection.DIRECT);
6084
}
6185

86+
/**
87+
* Declares a Set multi-binding dependency.
88+
*
89+
* <p>Such dependencies provide access to a {@code Set<Foo>} to dependent components. Note that
90+
* the set is only filled with components that explicitly declare the intent to be a "set"
91+
* dependency via {@link Component#intoSet(Object, Class)}.
92+
*/
6293
public static Dependency setOf(Class<?> anInterface) {
6394
return new Dependency(anInterface, Type.SET, Injection.DIRECT);
6495
}
6596

97+
/**
98+
* Declares an optional dependency.
99+
*
100+
* <p>Optional dependencies can be missing at runtime(being {@code null}) and dependents must be
101+
* ready to handle that.
102+
*/
66103
public static Dependency optionalProvider(Class<?> anInterface) {
67104
return new Dependency(anInterface, Type.OPTIONAL, Injection.PROVIDER);
68105
}
69106

107+
/**
108+
* Declares a required dependency.
109+
*
110+
* <p>Such dependencies must be present in order for the dependent component to function. Any
111+
* component with a required dependency should also declare a Maven dependency on an SDK that
112+
* provides it. Failing to do so will result in a {@link MissingDependencyException} to be thrown
113+
* at runtime.
114+
*/
70115
public static Dependency requiredProvider(Class<?> anInterface) {
71116
return new Dependency(anInterface, Type.REQUIRED, Injection.PROVIDER);
72117
}
73118

119+
/**
120+
* Declares a Set multi-binding dependency.
121+
*
122+
* <p>Such dependencies provide access to a {@code Set<Foo>} to dependent components. Note that
123+
* the set is only filled with components that explicitly declare the intent to be a "set"
124+
* dependency via {@link Component#intoSet(Object, Class)}.
125+
*/
74126
public static Dependency setOfProvider(Class<?> anInterface) {
75127
return new Dependency(anInterface, Type.SET, Injection.PROVIDER);
76128
}

0 commit comments

Comments
 (0)