package com.google.firebase.components; import com.airbnb.deeplinkdispatch.UrlTreeKt; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.Set; /* loaded from: classes.dex */ public final class Component { private final Set dependencies; private final ComponentFactory factory; private final int instantiation; private final String name; private final Set> providedInterfaces; private final Set> publishedEvents; private final int type; /* JADX INFO: Access modifiers changed from: package-private */ public static /* synthetic */ Object lambda$intoSet$2(Object obj, ComponentContainer componentContainer) { return obj; } /* JADX INFO: Access modifiers changed from: package-private */ public static /* synthetic */ Object lambda$of$1(Object obj, ComponentContainer componentContainer) { return obj; } private Component(String str, Set> set, Set set2, int i, int i2, ComponentFactory componentFactory, Set> set3) { this.name = str; this.providedInterfaces = Collections.unmodifiableSet(set); this.dependencies = Collections.unmodifiableSet(set2); this.instantiation = i; this.type = i2; this.factory = componentFactory; this.publishedEvents = Collections.unmodifiableSet(set3); } public final Component withFactory(ComponentFactory componentFactory) { return new Component<>(this.name, this.providedInterfaces, this.dependencies, this.instantiation, this.type, componentFactory, this.publishedEvents); } public final String toString() { StringBuilder sb = new StringBuilder("Component<"); sb.append(Arrays.toString(this.providedInterfaces.toArray())); sb.append(">{"); sb.append(this.instantiation); sb.append(", type="); sb.append(this.type); sb.append(", deps="); sb.append(Arrays.toString(this.dependencies.toArray())); sb.append(UrlTreeKt.componentParamSuffix); return sb.toString(); } public static Builder builder(Class cls) { return new Builder<>(cls, new Class[0]); } @SafeVarargs public static Builder builder(Class cls, Class... clsArr) { return new Builder<>(cls, clsArr); } @SafeVarargs public static Component of(final T t, Class cls, Class... clsArr) { return builder(cls, clsArr).factory(new ComponentFactory(t) { // from class: com.google.firebase.components.Component$$ExternalSyntheticLambda0 public final Object f$0; @Override // com.google.firebase.components.ComponentFactory public final Object create(ComponentContainer componentContainer) { return Component.lambda$of$1(this.f$0, componentContainer); } { this.f$0 = t; } }).build(); } public static Builder intoSetBuilder(Class cls) { return builder(cls).intoSet(); } public static Component intoSet(final T t, Class cls) { return intoSetBuilder(cls).factory(new ComponentFactory(t) { // from class: com.google.firebase.components.Component$$ExternalSyntheticLambda1 public final Object f$0; @Override // com.google.firebase.components.ComponentFactory public final Object create(ComponentContainer componentContainer) { return Component.lambda$intoSet$2(this.f$0, componentContainer); } { this.f$0 = t; } }).build(); } /* loaded from: classes.dex */ public static class Builder { private final Set dependencies; private ComponentFactory factory; private int instantiation; private String name; private final Set> providedInterfaces; private Set> publishedEvents; private int type; @SafeVarargs private Builder(Class cls, Class... clsArr) { this.name = null; HashSet hashSet = new HashSet(); this.providedInterfaces = hashSet; this.dependencies = new HashSet(); this.instantiation = 0; this.type = 0; this.publishedEvents = new HashSet(); Preconditions.checkNotNull(cls, "Null interface"); hashSet.add(cls); for (Class cls2 : clsArr) { Preconditions.checkNotNull(cls2, "Null interface"); } Collections.addAll(this.providedInterfaces, clsArr); } public Builder add(Dependency dependency) { Preconditions.checkNotNull(dependency, "Null dependency"); validateInterface(dependency.getInterface()); this.dependencies.add(dependency); return this; } public Builder alwaysEager() { return setInstantiation(1); } public Builder eagerInDefaultApp() { return setInstantiation(2); } private Builder setInstantiation(int i) { Preconditions.checkState(this.instantiation == 0, "Instantiation type has already been set."); this.instantiation = i; return this; } private void validateInterface(Class cls) { Preconditions.checkArgument(!this.providedInterfaces.contains(cls), "Components are not allowed to depend on interfaces they themselves provide."); } public Builder factory(ComponentFactory componentFactory) { this.factory = (ComponentFactory) Preconditions.checkNotNull(componentFactory, "Null factory"); return this; } public Component build() { Preconditions.checkState(this.factory != null, "Missing required property: factory."); return new Component<>(this.name, new HashSet(this.providedInterfaces), new HashSet(this.dependencies), this.instantiation, this.type, this.factory, this.publishedEvents); } /* JADX INFO: Access modifiers changed from: private */ public Builder intoSet() { this.type = 1; return this; } } public final boolean isValue() { return this.type == 0; } public final boolean isEagerInDefaultApp() { return this.instantiation == 2; } public final boolean isAlwaysEager() { return this.instantiation == 1; } public final Set> getPublishedEvents() { return this.publishedEvents; } public final Set> getProvidedInterfaces() { return this.providedInterfaces; } public final String getName() { return this.name; } public final ComponentFactory getFactory() { return this.factory; } public final Set getDependencies() { return this.dependencies; } }