what-the-bank/sources/com/google/firebase/components/RestrictedComponentContaine...

106 lines
4.8 KiB
Java

package com.google.firebase.components;
import com.google.firebase.events.Publisher;
import com.google.firebase.inject.Deferred;
import com.google.firebase.inject.Provider;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/* loaded from: classes.dex */
final class RestrictedComponentContainer extends AbstractComponentContainer {
private final Set<Class<?>> allowedDeferredInterfaces;
private final Set<Class<?>> allowedDirectInterfaces;
private final Set<Class<?>> allowedProviderInterfaces;
private final Set<Class<?>> allowedPublishedEvents;
private final Set<Class<?>> allowedSetDirectInterfaces;
private final Set<Class<?>> allowedSetProviderInterfaces;
private final ComponentContainer delegateContainer;
/* JADX INFO: Access modifiers changed from: package-private */
public RestrictedComponentContainer(Component<?> component, ComponentContainer componentContainer) {
HashSet hashSet = new HashSet();
HashSet hashSet2 = new HashSet();
HashSet hashSet3 = new HashSet();
HashSet hashSet4 = new HashSet();
HashSet hashSet5 = new HashSet();
for (Dependency dependency : component.getDependencies()) {
if (dependency.isDirectInjection()) {
if (dependency.isSet()) {
hashSet4.add(dependency.getInterface());
} else {
hashSet.add(dependency.getInterface());
}
} else if (dependency.isDeferred()) {
hashSet3.add(dependency.getInterface());
} else if (dependency.isSet()) {
hashSet5.add(dependency.getInterface());
} else {
hashSet2.add(dependency.getInterface());
}
}
if (!component.getPublishedEvents().isEmpty()) {
hashSet.add(Publisher.class);
}
this.allowedDirectInterfaces = Collections.unmodifiableSet(hashSet);
this.allowedProviderInterfaces = Collections.unmodifiableSet(hashSet2);
this.allowedDeferredInterfaces = Collections.unmodifiableSet(hashSet3);
this.allowedSetDirectInterfaces = Collections.unmodifiableSet(hashSet4);
this.allowedSetProviderInterfaces = Collections.unmodifiableSet(hashSet5);
this.allowedPublishedEvents = component.getPublishedEvents();
this.delegateContainer = componentContainer;
}
@Override // com.google.firebase.components.AbstractComponentContainer, com.google.firebase.components.ComponentContainer
public final <T> T get(Class<T> cls) {
if (!this.allowedDirectInterfaces.contains(cls)) {
throw new DependencyException(String.format("Attempting to request an undeclared dependency %s.", cls));
}
T t = (T) this.delegateContainer.get(cls);
return !cls.equals(Publisher.class) ? t : (T) new RestrictedPublisher(this.allowedPublishedEvents, (Publisher) t);
}
@Override // com.google.firebase.components.ComponentContainer
public final <T> Provider<T> getProvider(Class<T> cls) {
if (!this.allowedProviderInterfaces.contains(cls)) {
throw new DependencyException(String.format("Attempting to request an undeclared dependency Provider<%s>.", cls));
}
return this.delegateContainer.getProvider(cls);
}
@Override // com.google.firebase.components.ComponentContainer
public final <T> Deferred<T> getDeferred(Class<T> cls) {
if (!this.allowedDeferredInterfaces.contains(cls)) {
throw new DependencyException(String.format("Attempting to request an undeclared dependency Deferred<%s>.", cls));
}
return this.delegateContainer.getDeferred(cls);
}
@Override // com.google.firebase.components.ComponentContainer
public final <T> Provider<Set<T>> setOfProvider(Class<T> cls) {
if (!this.allowedSetProviderInterfaces.contains(cls)) {
throw new DependencyException(String.format("Attempting to request an undeclared dependency Provider<Set<%s>>.", cls));
}
return this.delegateContainer.setOfProvider(cls);
}
@Override // com.google.firebase.components.AbstractComponentContainer, com.google.firebase.components.ComponentContainer
public final <T> Set<T> setOf(Class<T> cls) {
if (!this.allowedSetDirectInterfaces.contains(cls)) {
throw new DependencyException(String.format("Attempting to request an undeclared dependency Set<%s>.", cls));
}
return this.delegateContainer.setOf(cls);
}
/* loaded from: classes.dex */
static class RestrictedPublisher implements Publisher {
private final Set<Class<?>> allowedPublishedEvents;
private final Publisher delegate;
public RestrictedPublisher(Set<Class<?>> set, Publisher publisher) {
this.allowedPublishedEvents = set;
this.delegate = publisher;
}
}
}