// Path: cassandra-migration/src/main/java/org/cognitor/cassandra/migration/MigrationException.java
// public class MigrationException extends RuntimeException {
//     private final String scriptName;
//     private final String statement;
// 
//     public MigrationException(String message, String scriptName) {
//         this(message, null, scriptName);
//     }
// 
//     public MigrationException(String message, Throwable cause) {
//         this(message, cause, null, null);
//     }
// 
//     public MigrationException(String message, Throwable cause, String scriptName) {
//         this(message, cause, scriptName, null);
//     }
// 
//     public MigrationException(String message, Throwable cause, String scriptName, String statement) {
//         super(message, cause);
//         this.scriptName = scriptName;
//         this.statement = statement;
//     }
// 
//     /**
//      * The name of the script that was involved in the error. Usually
//      * the script that contains a faulty statement. If the process did
//      * not arrive yet at script execution this will be null.
//      *
//      * @return the name of the failing script or null if there was a different kind of error
//      */
//     public String getScriptName() {
//         return scriptName;
//     }
// 
//     /**
//      * The statement that caused the migration to fail. This
//      * is helpful in case there is more than one statement inside a script.
//      *
//      * @return the failing statement or null if the exception was not thrown
//      *          during statement execution
//      */
//     public String getStatement() {
//         return statement;
//     }
// }


import org.cognitor.cassandra.migration.MigrationException;
import java.util.*;
import static java.lang.String.format;
package org.cognitor.cassandra.migration.collector;




/**
 * This strategy throws a {@link MigrationException} when there are two different
 * migration scripts with the same version inside the repository. It will fail immediately
 * and the collector process is interrupted.
 *
 * This is the default script collection strategy as it is a common problem in
 * projects with many developers or branches.
 *
 * @author Patrick Kranz
 */
public class FailOnDuplicatesCollector implements ScriptCollector {
    private final List<ScriptFile> scripts = new ArrayList<>();
    private final Set<Integer> versions = new HashSet<>();

    /**
     * {@inheritDoc}
     *
     * Checks for every <code>scriptFile</code> that was added if there was
     * already a script with the same version added. Throws an exception of
     * it is the case.
     *
     * @param scriptFile an object containing information about the script. Never null.
     * @throws MigrationException if a two different scripts with the same version are added
     */
    @Override
    public void collect(ScriptFile scriptFile) {
        if (!versions.contains(scriptFile.getVersion())) {
            scripts.add(scriptFile);
            versions.add(scriptFile.getVersion());
        } else {
// Path: cassandra-migration/src/main/java/org/cognitor/cassandra/migration/MigrationException.java
// public class MigrationException extends RuntimeException {
//     private final String scriptName;
//     private final String statement;
// 
//     public MigrationException(String message, String scriptName) {
//         this(message, null, scriptName);
//     }
// 
//     public MigrationException(String message, Throwable cause) {
//         this(message, cause, null, null);
//     }
// 
//     public MigrationException(String message, Throwable cause, String scriptName) {
//         this(message, cause, scriptName, null);
//     }
// 
//     public MigrationException(String message, Throwable cause, String scriptName, String statement) {
//         super(message, cause);
//         this.scriptName = scriptName;
//         this.statement = statement;
//     }
// 
//     /**
//      * The name of the script that was involved in the error. Usually
//      * the script that contains a faulty statement. If the process did
//      * not arrive yet at script execution this will be null.
//      *
//      * @return the name of the failing script or null if there was a different kind of error
//      */
//     public String getScriptName() {
//         return scriptName;
//     }
// 
//     /**
//      * The statement that caused the migration to fail. This
//      * is helpful in case there is more than one statement inside a script.
//      *
//      * @return the failing statement or null if the exception was not thrown
//      *          during statement execution
//      */
//     public String getStatement() {
//         return statement;
//     }
// }


// Path: cassandra-migration/src/main/java/org/cognitor/cassandra/migration/collector/FailOnDuplicatesCollector.java
import org.cognitor.cassandra.migration.MigrationException;
import java.util.*;
import static java.lang.String.format;

package org.cognitor.cassandra.migration.collector;




/**
 * This strategy throws a {@link MigrationException} when there are two different
 * migration scripts with the same version inside the repository. It will fail immediately
 * and the collector process is interrupted.
 *
 * This is the default script collection strategy as it is a common problem in
 * projects with many developers or branches.
 *
 * @author Patrick Kranz
 */
public class FailOnDuplicatesCollector implements ScriptCollector {
    private final List<ScriptFile> scripts = new ArrayList<>();
    private final Set<Integer> versions = new HashSet<>();

    /**
     * {@inheritDoc}
     *
     * Checks for every <code>scriptFile</code> that was added if there was
     * already a script with the same version added. Throws an exception of
     * it is the case.
     *
     * @param scriptFile an object containing information about the script. Never null.
     * @throws MigrationException if a two different scripts with the same version are added
     */
    @Override
    public void collect(ScriptFile scriptFile) {
        if (!versions.contains(scriptFile.getVersion())) {
            scripts.add(scriptFile);
            versions.add(scriptFile.getVersion());
        } else {
            throw new MigrationException(