what-the-bank/sources/io/grpc/ConnectivityStateInfo.java

57 lines
2.0 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package io.grpc;
import com.google.common.base.Preconditions;
/* loaded from: classes6.dex */
public final class ConnectivityStateInfo {
private final ConnectivityState state;
private final Status status;
public static ConnectivityStateInfo forNonError(ConnectivityState connectivityState) {
Preconditions.checkArgument(connectivityState != ConnectivityState.TRANSIENT_FAILURE, "state is TRANSIENT_ERROR. Use forError() instead");
return new ConnectivityStateInfo(connectivityState, Status.OK);
}
public static ConnectivityStateInfo forTransientFailure(Status status) {
Preconditions.checkArgument(!status.isOk(), "The error status must not be OK");
return new ConnectivityStateInfo(ConnectivityState.TRANSIENT_FAILURE, status);
}
public final boolean equals(Object obj) {
if (!(obj instanceof ConnectivityStateInfo)) {
return false;
}
ConnectivityStateInfo connectivityStateInfo = (ConnectivityStateInfo) obj;
return this.state.equals(connectivityStateInfo.state) && this.status.equals(connectivityStateInfo.status);
}
public final int hashCode() {
return this.state.hashCode() ^ this.status.hashCode();
}
public final String toString() {
if (this.status.isOk()) {
return this.state.toString();
}
StringBuilder sb = new StringBuilder();
sb.append(this.state);
sb.append("(");
sb.append(this.status);
sb.append(")");
return sb.toString();
}
private ConnectivityStateInfo(ConnectivityState connectivityState, Status status) {
this.state = (ConnectivityState) Preconditions.checkNotNull(connectivityState, "state is null");
this.status = (Status) Preconditions.checkNotNull(status, "status is null");
}
public final Status getStatus() {
return this.status;
}
public final ConnectivityState getState() {
return this.state;
}
}