51 lines
1.2 KiB
Java
51 lines
1.2 KiB
Java
|
package androidx.core.util;
|
||
|
|
||
|
import androidx.annotation.NonNull;
|
||
|
import androidx.annotation.Nullable;
|
||
|
import c.d.b.a.a;
|
||
|
public class Pair<F, S> {
|
||
|
@Nullable
|
||
|
public final F first;
|
||
|
@Nullable
|
||
|
public final S second;
|
||
|
|
||
|
public Pair(@Nullable F f, @Nullable S s2) {
|
||
|
this.first = f;
|
||
|
this.second = s2;
|
||
|
}
|
||
|
|
||
|
@NonNull
|
||
|
public static <A, B> Pair<A, B> create(@Nullable A a, @Nullable B b) {
|
||
|
return new Pair<>(a, b);
|
||
|
}
|
||
|
|
||
|
public boolean equals(Object obj) {
|
||
|
if (!(obj instanceof Pair)) {
|
||
|
return false;
|
||
|
}
|
||
|
Pair pair = (Pair) obj;
|
||
|
return ObjectsCompat.equals(pair.first, this.first) && ObjectsCompat.equals(pair.second, this.second);
|
||
|
}
|
||
|
|
||
|
public int hashCode() {
|
||
|
F f = this.first;
|
||
|
int i = 0;
|
||
|
int hashCode = f == null ? 0 : f.hashCode();
|
||
|
S s2 = this.second;
|
||
|
if (s2 != null) {
|
||
|
i = s2.hashCode();
|
||
|
}
|
||
|
return hashCode ^ i;
|
||
|
}
|
||
|
|
||
|
@NonNull
|
||
|
public String toString() {
|
||
|
StringBuilder K = a.K("Pair{");
|
||
|
K.append(String.valueOf(this.first));
|
||
|
K.append(" ");
|
||
|
K.append(String.valueOf(this.second));
|
||
|
K.append("}");
|
||
|
return K.toString();
|
||
|
}
|
||
|
}
|