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

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

package internal.io.text;

import lombok.NonNull;
import nbbrd.io.FileParser;
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.nio.charset.Charset;
import java.nio.file.Path;

@lombok.AllArgsConstructor
public final class WithCharsetFileParser implements FileParser {

    @NonNull
    private final TextParser delegate;

    @NonNull
    private final Charset charset;

    @Override
    public @NonNull T parseFile(@NonNull File source) throws IOException {
        return delegate.parseFile(source, charset);
    }

    @Override
    public @NonNull T parsePath(@NonNull Path source) throws IOException {
        return delegate.parsePath(source, charset);
    }

    @Override
    public @NonNull T parseResource(@NonNull Class type, @NonNull String name) throws IOException {
        return delegate.parseResource(type, name, charset);
    }

    @Override
    public @NonNull T parseStream(@NonNull IOSupplier source) throws IOException {
        return delegate.parseStream(source, charset);
    }

    @Override
    public @NonNull T parseStream(@NonNull InputStream inputStream) throws IOException {
        return delegate.parseStream(inputStream, charset);
    }

    @Override
    public  @NonNull FileParser andThen(@NonNull IOFunction after) {
        return new WithCharsetFileParser<>(delegate.andThen(after), charset);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy