Make Pair a record

This commit is contained in:
dfsek
2026-01-01 20:09:52 -07:00
parent eb6b3704d0
commit 47bdd66fe7
11 changed files with 24 additions and 49 deletions

View File

@@ -17,15 +17,8 @@ import java.util.function.Function;
import java.util.function.Predicate;
public final class Pair<L, R> {
public record Pair<L, R>(L left, R right) implements Bifunctor{
private static final Pair<?, ?> NULL = new Pair<>(null, null);
private final L left;
private final R right;
private Pair(L left, R right) {
this.left = left;
this.right = right;
}
public static <L, R, T> Function<Pair<L, R>, Pair<T, R>> mapLeft(Function<L, T> function) {
return pair -> of(function.apply(pair.left), pair.right);
@@ -76,19 +69,6 @@ public final class Pair<L, R> {
return Mutable.of(left, right);
}
public R getRight() {
return right;
}
public L getLeft() {
return left;
}
@Override
public int hashCode() {
return Objects.hash(left, right);
}
@Override
public boolean equals(Object obj) {
if(!(obj instanceof Pair<?, ?> that)) return false;