alexandroid/decompiled/jadx/sources/com/google/common/graph/EndpointPair.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

180 lines
6 KiB
Java

package com.google.common.graph;
import androidx.biometric.ErrorUtils$$ExternalSyntheticOutline0;
import com.amazon.alexa.ra.core.ui.markdown.parser.formatter.MarkdownConstants;
import com.google.common.annotations.Beta;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.collect.Iterators;
import com.google.common.collect.UnmodifiableIterator;
import com.google.errorprone.annotations.Immutable;
import java.util.Iterator;
import rx.Single$$ExternalSyntheticBUOutline0;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
@Immutable(containerOf = {"N"})
@Beta
/* loaded from: classes8.dex */
public abstract class EndpointPair<N> implements Iterable<N> {
private final N nodeU;
private final N nodeV;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
public static final class Ordered<N> extends EndpointPair<N> {
private Ordered(N n, N n2) {
super(n, n2);
}
@Override // com.google.common.graph.EndpointPair
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof EndpointPair)) {
return false;
}
EndpointPair endpointPair = (EndpointPair) obj;
return isOrdered() == endpointPair.isOrdered() && source().equals(endpointPair.source()) && target().equals(endpointPair.target());
}
@Override // com.google.common.graph.EndpointPair
public int hashCode() {
return Objects.hashCode(source(), target());
}
@Override // com.google.common.graph.EndpointPair
public boolean isOrdered() {
return true;
}
@Override // com.google.common.graph.EndpointPair, java.lang.Iterable
public /* bridge */ /* synthetic */ Iterator iterator() {
return iterator();
}
@Override // com.google.common.graph.EndpointPair
public N source() {
return nodeU();
}
@Override // com.google.common.graph.EndpointPair
public N target() {
return nodeV();
}
public String toString() {
StringBuilder sb = new StringBuilder("<");
sb.append(source());
sb.append(" -> ");
return ErrorUtils$$ExternalSyntheticOutline0.m(sb, ">", target());
}
}
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
public static final class Unordered<N> extends EndpointPair<N> {
private Unordered(N n, N n2) {
super(n, n2);
}
@Override // com.google.common.graph.EndpointPair
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof EndpointPair)) {
return false;
}
EndpointPair endpointPair = (EndpointPair) obj;
if (isOrdered() != endpointPair.isOrdered()) {
return false;
}
return nodeU().equals(endpointPair.nodeU()) ? nodeV().equals(endpointPair.nodeV()) : nodeU().equals(endpointPair.nodeV()) && nodeV().equals(endpointPair.nodeU());
}
@Override // com.google.common.graph.EndpointPair
public int hashCode() {
return nodeV().hashCode() + nodeU().hashCode();
}
@Override // com.google.common.graph.EndpointPair
public boolean isOrdered() {
return false;
}
@Override // com.google.common.graph.EndpointPair, java.lang.Iterable
public /* bridge */ /* synthetic */ Iterator iterator() {
return iterator();
}
@Override // com.google.common.graph.EndpointPair
public N source() {
throw new UnsupportedOperationException("Cannot call source()/target() on a EndpointPair from an undirected graph. Consider calling adjacentNode(node) if you already have a node, or nodeU()/nodeV() if you don't.");
}
@Override // com.google.common.graph.EndpointPair
public N target() {
throw new UnsupportedOperationException("Cannot call source()/target() on a EndpointPair from an undirected graph. Consider calling adjacentNode(node) if you already have a node, or nodeU()/nodeV() if you don't.");
}
public String toString() {
return MarkdownConstants.LEFT_BRACKET + nodeU() + ", " + nodeV() + MarkdownConstants.RIGHT_BRACKET;
}
}
private EndpointPair(N n, N n2) {
this.nodeU = (N) Preconditions.checkNotNull(n);
this.nodeV = (N) Preconditions.checkNotNull(n2);
}
public static <N> EndpointPair<N> of(Graph<?> graph, N n, N n2) {
return graph.isDirected() ? ordered(n, n2) : unordered(n, n2);
}
public static <N> EndpointPair<N> ordered(N n, N n2) {
return new Ordered(n, n2);
}
public static <N> EndpointPair<N> unordered(N n, N n2) {
return new Unordered(n2, n);
}
public final N adjacentNode(N n) {
boolean equals = n.equals(this.nodeU);
N n2 = this.nodeV;
if (equals) {
return n2;
}
if (n.equals(n2)) {
return this.nodeU;
}
Single$$ExternalSyntheticBUOutline0.m("EndpointPair ", this, " does not contain node ", n);
return null;
}
public abstract boolean equals(Object obj);
public abstract int hashCode();
public abstract boolean isOrdered();
@Override // java.lang.Iterable
public final UnmodifiableIterator<N> iterator() {
return Iterators.forArray(this.nodeU, this.nodeV);
}
public final N nodeU() {
return this.nodeU;
}
public final N nodeV() {
return this.nodeV;
}
public abstract N source();
public abstract N target();
public static <N> EndpointPair<N> of(Network<?, ?> network, N n, N n2) {
return network.isDirected() ? ordered(n, n2) : unordered(n, n2);
}
}