All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.minestom.server.utils.Either Maven / Gradle / Ivy

There is a newer version: 7320437640
Show newest version
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 - 2024 Weber Informatics LLC | Privacy Policy