// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
// 
//     public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
//         super(type, id, plain, ref, updatePolicy);
//     }
// 
// }
// 
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
// 
//     public VcsException(String message) {
//         super(message);
//     }
// 
//     public VcsException(String message, Throwable cause) {
//         super(messageFor(message, cause), cause);
//     }
// 
//     public VcsException(Throwable cause) {
//         this(null, cause);
//     }
// 
//     protected static String messageFor(String message, Throwable cause) {
//         if (isNotEmpty(message)) {
//             return message;
//         }
//         if (cause != null) {
//             final String causeMessage = cause.getMessage();
//             if (isNotEmpty(causeMessage)) {
//                 return causeMessage;
//             }
//         }
//         return null;
//     }
// 
// }
// 
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
// 
//     public VcsValidationException(String message) {
//         super(message);
//     }
// 
//     public VcsValidationException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public VcsValidationException(Throwable cause) {
//         super(cause);
//     }
// 
// }


import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.apache.commons.lang3.StringUtils.isEmpty;
package org.echocat.gradle.plugins.golang.vcs.isps;




public abstract class IspBasedVcsRepositoryProviderSupport extends VcsRepositoryProviderSupport {

    @Nullable
    private final String _prefix;

    public IspBasedVcsRepositoryProviderSupport(@Nullable String prefix, @Nonnull Pattern dependencyPattern) {
        super(dependencyPattern);
        _prefix = prefix;
    }

    @Override
    protected boolean couldHandle(@Nonnull RawVcsReference rawReference) {
        final String name = rawReference.getId();
        return name.startsWith(prefix());
    }

    @Override
    @Nonnull
    protected Matcher nameMatcherFor(@Nonnull RawVcsReference rawReference) throws VcsException {
        final Matcher matcher = dependencyPattern().matcher(rawReference.getId());
        if (!matcher.matches()) {
            throw new VcsValidationException("Name of dependency " + rawReference + " is invalid for " + getName() + ".");
        }
        return matcher;
    }

    @Nonnull
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
// 
//     public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
//         super(type, id, plain, ref, updatePolicy);
//     }
// 
// }
// 
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
// 
//     public VcsException(String message) {
//         super(message);
//     }
// 
//     public VcsException(String message, Throwable cause) {
//         super(messageFor(message, cause), cause);
//     }
// 
//     public VcsException(Throwable cause) {
//         this(null, cause);
//     }
// 
//     protected static String messageFor(String message, Throwable cause) {
//         if (isNotEmpty(message)) {
//             return message;
//         }
//         if (cause != null) {
//             final String causeMessage = cause.getMessage();
//             if (isNotEmpty(causeMessage)) {
//                 return causeMessage;
//             }
//         }
//         return null;
//     }
// 
// }
// 
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
// 
//     public VcsValidationException(String message) {
//         super(message);
//     }
// 
//     public VcsValidationException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public VcsValidationException(Throwable cause) {
//         super(cause);
//     }
// 
// }


// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/IspBasedVcsRepositoryProviderSupport.java
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.apache.commons.lang3.StringUtils.isEmpty;

package org.echocat.gradle.plugins.golang.vcs.isps;




public abstract class IspBasedVcsRepositoryProviderSupport extends VcsRepositoryProviderSupport {

    @Nullable
    private final String _prefix;

    public IspBasedVcsRepositoryProviderSupport(@Nullable String prefix, @Nonnull Pattern dependencyPattern) {
        super(dependencyPattern);
        _prefix = prefix;
    }

    @Override
    protected boolean couldHandle(@Nonnull RawVcsReference rawReference) {
        final String name = rawReference.getId();
        return name.startsWith(prefix());
    }

    @Override
    @Nonnull
    protected Matcher nameMatcherFor(@Nonnull RawVcsReference rawReference) throws VcsException {
        final Matcher matcher = dependencyPattern().matcher(rawReference.getId());
        if (!matcher.matches()) {
            throw new VcsValidationException("Name of dependency " + rawReference + " is invalid for " + getName() + ".");
        }
        return matcher;
    }

    @Nonnull
    protected String prefix() {