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

72 lines
3.1 KiB
Java

package com.google.common.graph;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.graph.ElementOrder;
import com.google.common.graph.ImmutableValueGraph;
/* loaded from: classes2.dex */
public final class ValueGraphBuilder<N, V> extends AbstractGraphBuilder<N> {
/* JADX WARN: Multi-variable type inference failed */
private <N1 extends N, V1 extends V> ValueGraphBuilder<N1, V1> cast() {
return this;
}
private ValueGraphBuilder(boolean z) {
super(z);
}
public static ValueGraphBuilder<Object, Object> directed() {
return new ValueGraphBuilder<>(true);
}
public static ValueGraphBuilder<Object, Object> undirected() {
return new ValueGraphBuilder<>(false);
}
public static <N, V> ValueGraphBuilder<N, V> from(ValueGraph<N, V> valueGraph) {
return new ValueGraphBuilder(valueGraph.isDirected()).allowsSelfLoops(valueGraph.allowsSelfLoops()).nodeOrder(valueGraph.nodeOrder()).incidentEdgeOrder(valueGraph.incidentEdgeOrder());
}
public final <N1 extends N, V1 extends V> ImmutableValueGraph.Builder<N1, V1> immutable() {
return new ImmutableValueGraph.Builder<>(cast());
}
public final ValueGraphBuilder<N, V> allowsSelfLoops(boolean z) {
this.allowsSelfLoops = z;
return this;
}
public final ValueGraphBuilder<N, V> expectedNodeCount(int i) {
this.expectedNodeCount = Optional.of(Integer.valueOf(Graphs.checkNonNegative(i)));
return this;
}
public final <N1 extends N> ValueGraphBuilder<N1, V> nodeOrder(ElementOrder<N1> elementOrder) {
ValueGraphBuilder<N1, V> valueGraphBuilder = (ValueGraphBuilder<N1, V>) cast();
valueGraphBuilder.nodeOrder = (ElementOrder) Preconditions.checkNotNull(elementOrder);
return valueGraphBuilder;
}
public final <N1 extends N> ValueGraphBuilder<N1, V> incidentEdgeOrder(ElementOrder<N1> elementOrder) {
Preconditions.checkArgument(elementOrder.type() == ElementOrder.Type.UNORDERED || elementOrder.type() == ElementOrder.Type.STABLE, "The given elementOrder (%s) is unsupported. incidentEdgeOrder() only supports ElementOrder.unordered() and ElementOrder.stable().", elementOrder);
ValueGraphBuilder<N1, V> valueGraphBuilder = (ValueGraphBuilder<N1, V>) cast();
valueGraphBuilder.incidentEdgeOrder = (ElementOrder) Preconditions.checkNotNull(elementOrder);
return valueGraphBuilder;
}
public final <N1 extends N, V1 extends V> MutableValueGraph<N1, V1> build() {
return new StandardMutableValueGraph(this);
}
/* JADX INFO: Access modifiers changed from: package-private */
public final ValueGraphBuilder<N, V> copy() {
ValueGraphBuilder<N, V> valueGraphBuilder = new ValueGraphBuilder<>(this.directed);
valueGraphBuilder.allowsSelfLoops = this.allowsSelfLoops;
valueGraphBuilder.nodeOrder = this.nodeOrder;
valueGraphBuilder.expectedNodeCount = this.expectedNodeCount;
valueGraphBuilder.incidentEdgeOrder = this.incidentEdgeOrder;
return valueGraphBuilder;
}
}