// Path: GerritStats/src/main/java/com/holmsted/gerrit/CommitFilter.java
// public class CommitFilter {
// 
//     @Nonnull
//     private final List<String> includedEmails = new ArrayList<>();
//     @Nonnull
//     private final List<String> excludedEmails = new ArrayList<>();
//     @Nonnull
//     private final List<String> includedBranches = new ArrayList<>();
// 
//     private boolean includeEmptyEmails;
// 
//     CommitFilter() {
//     }
// 
//     public void setIncludedEmails(@Nonnull List<String> excludeEmails) {
//         this.includedEmails.addAll(excludeEmails);
//     }
// 
//     public void setExcludedEmails(@Nonnull List<String> excludeEmails) {
//         this.excludedEmails.addAll(excludeEmails);
//     }
// 
//     public void setIncludeBranches(@Nonnull List<String> includeBranches) {
//         this.includedBranches.addAll(includeBranches);
//     }
// 
//     public void setIncludeEmptyEmails(boolean includeEmptyEmails) {
//         this.includeEmptyEmails = includeEmptyEmails;
//     }
// 
//     public boolean isIncluded(@Nonnull Commit commit) {
//         return includedBranches.isEmpty() || includedBranches.contains(commit.branch);
//     }
// 
//     public boolean isIncluded(@Nullable Commit.Identity identity) {
//         if (identity == null || identity.email == null) {
//             return includeEmptyEmails;
//         } else {
//             if (!includedEmails.isEmpty()) {
//                 return includedEmails.contains(identity.email);
//             } else {
//                 return !excludedEmails.contains(identity.email);
//             }
//         }
//     }
// }
// 
// Path: GerritStats/src/main/java/com/holmsted/gerrit/OutputRules.java
// public class OutputRules {
// 
//     public static final int INVALID_PATCH_COUNT = -1;
// 
//     @Nonnull
//     private final CommandLineParser commandLine;
// 
//     OutputRules(@Nonnull CommandLineParser commandLine) {
//         this.commandLine = commandLine;
//     }
// 
//     public String getOutputDir() {
//         return commandLine.getOutputDir();
//     }
// 
//     public boolean isAnonymizeDataEnabled() {
//         return commandLine.isAnonymizeDataEnabled();
//     }
// }
// 
// Path: GerritStats/src/main/java/com/holmsted/gerrit/QueryData.java
// public class QueryData {
//     @Nonnull
//     private final List<Commit> commits;
//     @Nonnull
//     private final List<String> filenames;
//     @Nonnull
//     private final GerritVersion minVersion;
// 
//     @Nonnull
//     private final List<String> branches;
// 
//     private String datasetKey;
// 
//     QueryData(@Nonnull List<String> filenames,
//               @Nonnull List<Commit> commits,
//               @Nonnull GerritVersion minVersion) {
// 
//         this.filenames = ImmutableList.copyOf(filenames);
//         this.commits = ImmutableList.copyOf(commits);
//         this.minVersion = minVersion;
//         this.branches = this.commits.stream().map(commit -> commit.branch)
//                 .distinct().collect(Collectors.toList());
//     }
// 
//     public String getDisplayableProjectName() {
//         return String.format("all data from file(s) %s", Joiner.on(", ").join(this.filenames));
//     }
// 
//     @Nonnull
//     public List<String> getFilenames() {
//         return this.filenames;
//     }
// 
//     public List<String> getBranches() {
//         return this.branches;
//     }
// 
//     @Nonnull
//     public List<Commit> getCommits() {
//         return commits;
//     }
// 
//     /**
//      * Returns a unique hashcode formed out of the filenames. This can be used as a rudimentary
//      * check for whether the data was generated with the same files.
//      */
//     @Nonnull
//     public String getDatasetKey() {
//         if (this.datasetKey == null) {
//             List<String> filenames = new ArrayList<>(getFilenames());
//             Collections.sort(filenames);
//             HashCodeBuilder hashCodeBuilder = new HashCodeBuilder();
//             for (String filename : filenames) {
//                 hashCodeBuilder.append(filename);
//             }
//             this.datasetKey = hashCodeBuilder.build().toString();
//         }
// 
//         return this.datasetKey;
//     }
// 
//     @Nonnull
//     public QueryData anonymize() {
//         CommitAnonymizer anonymizer = new CommitAnonymizer();
//         List<Commit> anonymizedCommits = anonymizer.process(commits);
//         return new QueryData(ImmutableList.of(), anonymizedCommits, minVersion);
//     }
// 
//     public GerritVersion getMinGerritVersion() {
//         return minVersion;
//     }
// }


import com.holmsted.gerrit.CommitFilter;
import com.holmsted.gerrit.OutputRules;
import com.holmsted.gerrit.QueryData;
import javax.annotation.Nonnull;
package com.holmsted.gerrit.processors;



public abstract class CommitDataProcessor<T> {

    @Nonnull
    private final CommitFilter filter;
    @Nonnull
    private final OutputRules outputRules;

    public interface OutputFormatter<T> {
        void format(@Nonnull T format);
    }

    public CommitDataProcessor(@Nonnull CommitFilter filter, @Nonnull OutputRules outputRules) {
        this.filter = filter;
        this.outputRules = outputRules;
    }

    /**
     * Processes the list of commits and builds output for it,
     * returning it as a string.
     */
    public void invoke(@Nonnull QueryData queryData) {
        OutputFormatter<T> formatter = createOutputFormatter();
        process(formatter, queryData);
    }

    protected abstract void process(@Nonnull OutputFormatter<T> formatter, @Nonnull QueryData queryData);

    @Nonnull
// Path: GerritStats/src/main/java/com/holmsted/gerrit/CommitFilter.java
// public class CommitFilter {
// 
//     @Nonnull
//     private final List<String> includedEmails = new ArrayList<>();
//     @Nonnull
//     private final List<String> excludedEmails = new ArrayList<>();
//     @Nonnull
//     private final List<String> includedBranches = new ArrayList<>();
// 
//     private boolean includeEmptyEmails;
// 
//     CommitFilter() {
//     }
// 
//     public void setIncludedEmails(@Nonnull List<String> excludeEmails) {
//         this.includedEmails.addAll(excludeEmails);
//     }
// 
//     public void setExcludedEmails(@Nonnull List<String> excludeEmails) {
//         this.excludedEmails.addAll(excludeEmails);
//     }
// 
//     public void setIncludeBranches(@Nonnull List<String> includeBranches) {
//         this.includedBranches.addAll(includeBranches);
//     }
// 
//     public void setIncludeEmptyEmails(boolean includeEmptyEmails) {
//         this.includeEmptyEmails = includeEmptyEmails;
//     }
// 
//     public boolean isIncluded(@Nonnull Commit commit) {
//         return includedBranches.isEmpty() || includedBranches.contains(commit.branch);
//     }
// 
//     public boolean isIncluded(@Nullable Commit.Identity identity) {
//         if (identity == null || identity.email == null) {
//             return includeEmptyEmails;
//         } else {
//             if (!includedEmails.isEmpty()) {
//                 return includedEmails.contains(identity.email);
//             } else {
//                 return !excludedEmails.contains(identity.email);
//             }
//         }
//     }
// }
// 
// Path: GerritStats/src/main/java/com/holmsted/gerrit/OutputRules.java
// public class OutputRules {
// 
//     public static final int INVALID_PATCH_COUNT = -1;
// 
//     @Nonnull
//     private final CommandLineParser commandLine;
// 
//     OutputRules(@Nonnull CommandLineParser commandLine) {
//         this.commandLine = commandLine;
//     }
// 
//     public String getOutputDir() {
//         return commandLine.getOutputDir();
//     }
// 
//     public boolean isAnonymizeDataEnabled() {
//         return commandLine.isAnonymizeDataEnabled();
//     }
// }
// 
// Path: GerritStats/src/main/java/com/holmsted/gerrit/QueryData.java
// public class QueryData {
//     @Nonnull
//     private final List<Commit> commits;
//     @Nonnull
//     private final List<String> filenames;
//     @Nonnull
//     private final GerritVersion minVersion;
// 
//     @Nonnull
//     private final List<String> branches;
// 
//     private String datasetKey;
// 
//     QueryData(@Nonnull List<String> filenames,
//               @Nonnull List<Commit> commits,
//               @Nonnull GerritVersion minVersion) {
// 
//         this.filenames = ImmutableList.copyOf(filenames);
//         this.commits = ImmutableList.copyOf(commits);
//         this.minVersion = minVersion;
//         this.branches = this.commits.stream().map(commit -> commit.branch)
//                 .distinct().collect(Collectors.toList());
//     }
// 
//     public String getDisplayableProjectName() {
//         return String.format("all data from file(s) %s", Joiner.on(", ").join(this.filenames));
//     }
// 
//     @Nonnull
//     public List<String> getFilenames() {
//         return this.filenames;
//     }
// 
//     public List<String> getBranches() {
//         return this.branches;
//     }
// 
//     @Nonnull
//     public List<Commit> getCommits() {
//         return commits;
//     }
// 
//     /**
//      * Returns a unique hashcode formed out of the filenames. This can be used as a rudimentary
//      * check for whether the data was generated with the same files.
//      */
//     @Nonnull
//     public String getDatasetKey() {
//         if (this.datasetKey == null) {
//             List<String> filenames = new ArrayList<>(getFilenames());
//             Collections.sort(filenames);
//             HashCodeBuilder hashCodeBuilder = new HashCodeBuilder();
//             for (String filename : filenames) {
//                 hashCodeBuilder.append(filename);
//             }
//             this.datasetKey = hashCodeBuilder.build().toString();
//         }
// 
//         return this.datasetKey;
//     }
// 
//     @Nonnull
//     public QueryData anonymize() {
//         CommitAnonymizer anonymizer = new CommitAnonymizer();
//         List<Commit> anonymizedCommits = anonymizer.process(commits);
//         return new QueryData(ImmutableList.of(), anonymizedCommits, minVersion);
//     }
// 
//     public GerritVersion getMinGerritVersion() {
//         return minVersion;
//     }
// }


// Path: GerritStats/src/main/java/com/holmsted/gerrit/processors/CommitDataProcessor.java
import com.holmsted.gerrit.CommitFilter;
import com.holmsted.gerrit.OutputRules;
import com.holmsted.gerrit.QueryData;
import javax.annotation.Nonnull;

package com.holmsted.gerrit.processors;



public abstract class CommitDataProcessor<T> {

    @Nonnull
    private final CommitFilter filter;
    @Nonnull
    private final OutputRules outputRules;

    public interface OutputFormatter<T> {
        void format(@Nonnull T format);
    }

    public CommitDataProcessor(@Nonnull CommitFilter filter, @Nonnull OutputRules outputRules) {
        this.filter = filter;
        this.outputRules = outputRules;
    }

    /**
     * Processes the list of commits and builds output for it,
     * returning it as a string.
     */
    public void invoke(@Nonnull QueryData queryData) {
        OutputFormatter<T> formatter = createOutputFormatter();
        process(formatter, queryData);
    }

    protected abstract void process(@Nonnull OutputFormatter<T> formatter, @Nonnull QueryData queryData);

    @Nonnull
    protected abstract OutputFormatter<T> createOutputFormatter();