Skip to content

Commit d40db69

Browse files
authored
Port crv to github (#4004)
* update component * update
1 parent 93fc7de commit d40db69

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

firebase-components/firebase-components.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ android {
4444
dependencies {
4545
implementation project(':firebase-annotations')
4646
implementation 'androidx.annotation:annotation:1.1.0'
47-
47+
implementation "com.google.errorprone:error_prone_annotations:2.9.0"
4848
testImplementation 'androidx.test:runner:1.2.0'
4949
testImplementation 'androidx.test.ext:junit:1.1.1'
5050
testImplementation "org.robolectric:robolectric:$robolectricVersion"

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import androidx.annotation.IntDef;
1818
import androidx.annotation.NonNull;
1919
import androidx.annotation.Nullable;
20+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
2021
import java.lang.annotation.Retention;
2122
import java.lang.annotation.RetentionPolicy;
2223
import java.util.Arrays;
@@ -265,6 +266,7 @@ public Builder<T> name(@NonNull String name) {
265266
}
266267

267268
/** Add a {@link Dependency} to the {@link Component} being built. */
269+
@CanIgnoreReturnValue
268270
public Builder<T> add(Dependency dependency) {
269271
Preconditions.checkNotNull(dependency, "Null dependency");
270272
validateInterface(dependency.getInterface());
@@ -273,21 +275,25 @@ public Builder<T> add(Dependency dependency) {
273275
}
274276

275277
/** Make the {@link Component} initialize upon startup. */
278+
@CanIgnoreReturnValue
276279
public Builder<T> alwaysEager() {
277280
return setInstantiation(Instantiation.ALWAYS_EAGER);
278281
}
279282

280283
/** Make the component initialize upon startup in default app. */
284+
@CanIgnoreReturnValue
281285
public Builder<T> eagerInDefaultApp() {
282286
return setInstantiation(Instantiation.EAGER_IN_DEFAULT_APP);
283287
}
284288

285289
/** Make the {@link Component} eligible to publish events of provided eventType. */
290+
@CanIgnoreReturnValue
286291
public Builder<T> publishes(Class<?> eventType) {
287292
publishedEvents.add(eventType);
288293
return this;
289294
}
290295

296+
@CanIgnoreReturnValue
291297
private Builder<T> setInstantiation(@Instantiation int instantiation) {
292298
Preconditions.checkState(
293299
this.instantiation == Instantiation.LAZY, "Instantiation type has already been set.");
@@ -302,11 +308,13 @@ private void validateInterface(Class<?> anInterface) {
302308
}
303309

304310
/** Set the factory that will be used to initialize the {@link Component}. */
311+
@CanIgnoreReturnValue
305312
public Builder<T> factory(ComponentFactory<T> value) {
306313
factory = Preconditions.checkNotNull(value, "Null factory");
307314
return this;
308315
}
309316

317+
@CanIgnoreReturnValue
310318
private Builder<T> intoSet() {
311319
type = ComponentType.SET;
312320
return this;

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import androidx.annotation.RestrictTo;
1919
import androidx.annotation.RestrictTo.Scope;
2020
import androidx.annotation.VisibleForTesting;
21+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
2122
import com.google.firebase.dynamicloading.ComponentLoader;
2223
import com.google.firebase.events.Publisher;
2324
import com.google.firebase.events.Subscriber;
@@ -358,21 +359,25 @@ public static final class Builder {
358359
this.defaultExecutor = defaultExecutor;
359360
}
360361

362+
@CanIgnoreReturnValue
361363
public Builder addLazyComponentRegistrars(Collection<Provider<ComponentRegistrar>> registrars) {
362364
this.lazyRegistrars.addAll(registrars);
363365
return this;
364366
}
365367

368+
@CanIgnoreReturnValue
366369
public Builder addComponentRegistrar(ComponentRegistrar registrar) {
367370
this.lazyRegistrars.add(() -> registrar);
368371
return this;
369372
}
370373

374+
@CanIgnoreReturnValue
371375
public Builder addComponent(Component<?> component) {
372376
this.additionalComponents.add(component);
373377
return this;
374378
}
375379

380+
@CanIgnoreReturnValue
376381
public Builder setProcessor(ComponentRegistrarProcessor processor) {
377382
this.componentRegistrarProcessor = processor;
378383
return this;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
package com.google.firebase.components;
1616

17+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
18+
1719
public final class Preconditions {
1820

1921
public static void checkArgument(boolean expression, String errorMessage) {
@@ -22,13 +24,15 @@ public static void checkArgument(boolean expression, String errorMessage) {
2224
}
2325
}
2426

27+
@CanIgnoreReturnValue
2528
public static <T> T checkNotNull(T reference) {
2629
if (reference == null) {
2730
throw new NullPointerException();
2831
}
2932
return reference;
3033
}
3134

35+
@CanIgnoreReturnValue
3236
public static <T> T checkNotNull(T reference, String errorMessage) {
3337
if (reference == null) {
3438
throw new NullPointerException(errorMessage);

0 commit comments

Comments
 (0)