
net.minestom.server.utils.Either Maven / Gradle / Ivy
package net.minestom.server.utils;
import java.util.function.Function;
public record Either(boolean isLeft, L left, R right) {
public static Either left(T left) {
return new Either<>(true, left, null);
}
public static Either right(T right) {
return new Either<>(false, null, right);
}
public T map(Function leftMapper, Function rightMapper) {
if (isLeft) {
return leftMapper.apply(left);
} else {
return rightMapper.apply(right);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy