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

internal.io.text.AndThenTextParser Maven / Gradle / Ivy

package internal.io.text;

import lombok.NonNull;
import nbbrd.io.function.IOFunction;
import nbbrd.io.function.IOSupplier;
import nbbrd.io.text.TextParser;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.nio.charset.Charset;
import java.nio.file.Path;

@lombok.AllArgsConstructor
public final class AndThenTextParser implements TextParser {

    @NonNull
    private final TextParser parser;

    @NonNull
    private final IOFunction after;

    @Override
    public @NonNull V parseChars(@NonNull CharSequence source) throws IOException {
        return after.applyWithIO(parser.parseChars(source));
    }

    @Override
    public @NonNull V parseFile(@NonNull File source, @NonNull Charset encoding) throws IOException {
        return after.applyWithIO(parser.parseFile(source, encoding));
    }

    @Override
    public @NonNull V parsePath(@NonNull Path source, @NonNull Charset encoding) throws IOException {
        return after.applyWithIO(parser.parsePath(source, encoding));
    }

    @Override
    public @NonNull V parseResource(@NonNull Class type, @NonNull String name, @NonNull Charset encoding) throws IOException {
        return after.applyWithIO(parser.parseResource(type, name, encoding));
    }

    @Override
    public @NonNull V parseReader(@NonNull IOSupplier source) throws IOException {
        return after.applyWithIO(parser.parseReader(source));
    }

    @Override
    public @NonNull V parseStream(@NonNull IOSupplier source, @NonNull Charset encoding) throws IOException {
        return after.applyWithIO(parser.parseStream(source, encoding));
    }

    @Override
    public @NonNull V parseReader(@NonNull Reader resource) throws IOException {
        return after.applyWithIO(parser.parseReader(resource));
    }

    @Override
    public @NonNull V parseStream(@NonNull InputStream resource, @NonNull Charset encoding) throws IOException {
        return after.applyWithIO(parser.parseStream(resource, encoding));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy