package com.atlassian.stash.internal.scm.git.command.merge;

import com.atlassian.bitbucket.scm.CommandOutputHandler;
import com.atlassian.utils.process.LineOutputHandler;
import com.google.common.collect.Sets;

import javax.annotation.Nonnull;
import java.util.Set;

/**
 * @since 1.3
 */
public class MergeBaseOutputHandler extends LineOutputHandler implements CommandOutputHandler<Set<String>> {

    private final Set<String> mergeBases;

    public MergeBaseOutputHandler() {
        super("UTF-8");

        mergeBases = Sets.newLinkedHashSet();
    }

    @Nonnull
    @Override
    public Set<String> getOutput() {
        return mergeBases;
    }

    @Override
    protected void processLine(int lineNumber, String line) {
        mergeBases.add(line);
    }
}
