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

internal.io.AndThenFileParser Maven / Gradle / Ivy

package internal.io;

import lombok.NonNull;
import nbbrd.io.FileParser;
import nbbrd.io.function.IOFunction;
import nbbrd.io.function.IOSupplier;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;

@lombok.AllArgsConstructor
public class AndThenFileParser implements FileParser {

    @NonNull
    protected final FileParser parser;

    @NonNull
    protected final IOFunction after;

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

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

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy