<commit_before>package javafixes.object;

import java.util.NoSuchElementException;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;

// todo: add javadoc - non biased implementation
// todo: add into readme
public abstract class Either<L, R> extends DataObject {

    private Either() {
    }

    public static <L, R> Either<L, R> right(R value) {
        return new Either.Right<L, R>(value);
    }

    public static <L, R> Either<L, R> left(L value) {
        return new Either.Left<L, R>(value);
    }

    public abstract Either<R, L> swap();

    public abstract boolean isLeft();

    public abstract boolean isRight();

    public abstract L getLeft() throws NoSuchElementException;

    public abstract R getRight() throws NoSuchElementException;

    public abstract <T extends Throwable> L getLeftOrThrow(Supplier<? extends T> exceptionSupplier) throws T;

    public abstract <T extends Throwable> R getRightOrThrow(Supplier<? extends T> exceptionSupplier) throws T;

    public abstract <L2, R2> Either<L2, R2> map(Function<L, L2> mapLeft, Function<R, R2> mapRight);

    public abstract <L2> Either<L2, R> mapLeft(Function<L, L2> mapLeft);

    public abstract <R2> Either<L, R2> mapRight(Function<R, R2> mapRight);

    public abstract <T> T fold(Function<L, T> foldLeft, Function<R, T> foldRight);

    public abstract Either<L, R> ifLeft(Consumer<? super L> action);

    public abstract Either<L, R> ifRight(Consumer<? super R> action);

    public abstract <T extends Throwable> Either<L, R> ifLeftThrow(Function<L, ? extends T> exceptionSupplier) throws T;

    public abstract <T extends Throwable> Either<L, R> ifRightThrow(Function<R, ? extends T> exceptionSupplier) throws T;

    /**
     * Returns left value if of type {@link Left} or right value if of type {@link Right}<commit_msg>mtymes: a bit more javadoc<commit_after>package javafixes.object;

import java.util.NoSuchElementException;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;

// todo: add javadoc - un/non biased implementation
// todo: add into readme
public abstract class Either<L, R> extends DataObject {

    private Either() {
    }

    public static <L, R> Either<L, R> right(R value) {
        return new Either.Right<L, R>(value);
    }

    public static <L, R> Either<L, R> left(L value) {
        return new Either.Left<L, R>(value);
    }

    public abstract Either<R, L> swap();

    public abstract boolean isLeft();

    public abstract boolean isRight();

    public abstract L getLeft() throws NoSuchElementException;

    public abstract R getRight() throws NoSuchElementException;

    public abstract <T extends Throwable> L getLeftOrThrow(Supplier<? extends T> exceptionSupplier) throws T;

    public abstract <T extends Throwable> R getRightOrThrow(Supplier<? extends T> exceptionSupplier) throws T;

    public abstract <L2, R2> Either<L2, R2> map(Function<L, L2> mapLeft, Function<R, R2> mapRight);

    public abstract <L2> Either<L2, R> mapLeft(Function<L, L2> mapLeft);

    public abstract <R2> Either<L, R2> mapRight(Function<R, R2> mapRight);

    public abstract <T> T fold(Function<L, T> foldLeft, Function<R, T> foldRight);

    /**
     * Executes provided {@code action} if value is defined as {@link Left Left} {@link Either}.
     * The {@code action} is ignored if value is defined as {@link Right Right} {@link Either}.
     *
     * @param action that is executed for {@link Left Left} {@link Either}
     * @return the same instance to allow method chaining
     */
    public abstract Either<L, R> ifLeft(Consumer<? super L> action);


    /**
     * Executes provided {@code action} if value is defined as {@link Right Right} {@link Either}.
     * The {@code action} is ignored if value is defined as {@link Left Left} {@link Either}.
     *
     * @param action that is executed for {@link Right Right} {@link Either}
     * @return the same instance to allow method chaining
     */
    public abstract Either<L, R> ifRight(Consumer<? super R> action);

    public abstract <T extends Throwable> Either<L, R> ifLeftThrow(Function<L, ? extends T> exceptionSupplier) throws T;

    public abstract <T extends Throwable> Either<L, R> ifRightThrow(Function<R, ? extends T> exceptionSupplier) throws T;

    /**
     * Returns left value if of type {@link Left} or right value if of type {@link Right}
{'fraction_non_alphanumeric': 0.10949068880412834, 'fraction_numerical': 0.0053847879739735245, 'mean_word_length': 3.8721311475409834, 'pattern_counts': {'":': 0, '<': 73, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6260188', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1293, 'n_words': 495}