
package com.asakusafw.runtime.io.text.directio;

/**
 * Utilities about {@link InputSplitter}.
 * @since 0.9.1
 */
public final class InputSplitters {

    private InputSplitters() {
        return;
    }

    /**
     * Returns an {@link InputSplitter} for LF separated text without line separator escape.
     * @return the {@link InputSplitter} for LF separated text
     * @see LineFeedDelimitedInputStream
     */
    public static InputSplitter byLineFeed() {
        return (input, offset, splitSize) -> {
            if (isWhole(offset, splitSize)) {
                return input;
            }
            return new LineFeedDelimitedInputStream(input, offset, splitSize);
        };
    }

    static boolean isWhole(long offset, long splitSize) {
        return offset == 0 && splitSize == Long.MAX_VALUE;
    }
}
