package com.atlassian.bitbucket.mesh.process.handler;

import javax.annotation.Nonnull;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

public class LinesStdioHandler extends AbstractLineStdioHandler<List<String>> {

    private final List<String> lines;

    public LinesStdioHandler() {
        super(StandardCharsets.UTF_8);

        lines = new ArrayList<>();
    }

    @Override
    public List<String> getResult() {
        return lines;
    }

    @Override
    protected boolean onStdout(@Nonnull String line, boolean truncated) {
        lines.add(line);
        return true;
    }
}
