what-the-bank/sources/com/google/common/graph/EdgesConnecting.java

45 lines
1.6 KiB
Java

package com.google.common.graph;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterators;
import com.google.common.collect.UnmodifiableIterator;
import java.util.AbstractSet;
import java.util.Map;
/* loaded from: classes2.dex */
final class EdgesConnecting<E> extends AbstractSet<E> {
private final Map<?, E> nodeToOutEdge;
private final Object targetNode;
/* JADX INFO: Access modifiers changed from: package-private */
public EdgesConnecting(Map<?, E> map, Object obj) {
this.nodeToOutEdge = (Map) Preconditions.checkNotNull(map);
this.targetNode = Preconditions.checkNotNull(obj);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.lang.Iterable, java.util.Set
public final UnmodifiableIterator<E> iterator() {
E connectingEdge = getConnectingEdge();
if (connectingEdge == null) {
return ImmutableSet.of().iterator();
}
return Iterators.singletonIterator(connectingEdge);
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final int size() {
return getConnectingEdge() == null ? 0 : 1;
}
@Override // java.util.AbstractCollection, java.util.Collection, java.util.Set
public final boolean contains(Object obj) {
E connectingEdge = getConnectingEdge();
return connectingEdge != null && connectingEdge.equals(obj);
}
private E getConnectingEdge() {
return this.nodeToOutEdge.get(this.targetNode);
}
}