what-the-bank/sources/com/google/firebase/firestore/model/DatabaseId.java

68 lines
2.2 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.firebase.firestore.model;
import com.google.firebase.firestore.util.Assert;
/* loaded from: classes2.dex */
public final class DatabaseId implements Comparable<DatabaseId> {
public static final DatabaseId EMPTY = forDatabase("", "");
private final String databaseId;
private final String projectId;
public static DatabaseId forDatabase(String str, String str2) {
return new DatabaseId(str, str2);
}
private DatabaseId(String str, String str2) {
this.projectId = str;
this.databaseId = str2;
}
public static DatabaseId fromName(String str) {
ResourcePath fromString = ResourcePath.fromString(str);
boolean z = false;
if (fromString.length() > 3 && fromString.getSegment(0).equals("projects") && fromString.getSegment(2).equals("databases")) {
z = true;
}
Assert.hardAssert(z, "Tried to parse an invalid resource name: %s", fromString);
return new DatabaseId(fromString.getSegment(1), fromString.getSegment(3));
}
public final String toString() {
StringBuilder sb = new StringBuilder("DatabaseId(");
sb.append(this.projectId);
sb.append(", ");
sb.append(this.databaseId);
sb.append(")");
return sb.toString();
}
public final boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
DatabaseId databaseId = (DatabaseId) obj;
return this.projectId.equals(databaseId.projectId) && this.databaseId.equals(databaseId.databaseId);
}
public final int hashCode() {
return (this.projectId.hashCode() * 31) + this.databaseId.hashCode();
}
@Override // java.lang.Comparable
public final int compareTo(DatabaseId databaseId) {
int compareTo = this.projectId.compareTo(databaseId.projectId);
return compareTo == 0 ? this.databaseId.compareTo(databaseId.databaseId) : compareTo;
}
public final String getProjectId() {
return this.projectId;
}
public final String getDatabaseId() {
return this.databaseId;
}
}