// Path: src/main/java/de/skuzzle/enforcer/restrictimports/parser/ImportStatement.java
// public final class ImportStatement {
// 
//     private static final String IMPORT_PREFIX = "import ";
//     private static final String STATIC_PREFIX = "static ";
//     private final String importName;
//     private final int line;
//     private final boolean staticImport;
// 
//     public ImportStatement(String importName, int line, boolean staticImport) {
//         Preconditions.checkArgument(importName != null && !importName.isEmpty(), "importName must not be empty");
//         Preconditions.checkArgument(!importName.startsWith(IMPORT_PREFIX),
//                 "importName should be the raw package name without 'import ' prefix but was: '%s'", importName);
//         Preconditions.checkArgument(!importName.startsWith(STATIC_PREFIX),
//                 "importName should be the raw package name without 'static ' prefix but was: '%s'", importName);
//         Preconditions.checkArgument(importName.trim().equals(importName),
//                 "importName has leading or trailing spaces: '%s'", importName);
//         Preconditions.checkArgument(line > 0, "line numbers should be 1-based and not start at 0");
// 
//         this.importName = importName;
//         this.line = line;
//         this.staticImport = staticImport;
//     }
// 
//     /**
//      * The physical line within the source file in which the import has occurred. Number
//      * is always 1-based!
//      *
//      * @return The line number of the matched imports.
//      */
//     public int getLine() {
//         return line;
//     }
// 
//     /**
//      * Returns the import name including the 'static ' prefix if this represents a static
//      * import.
//      *
//      * @return The full import name.
//      */
//     public String getImportName() {
//         if (staticImport) {
//             return STATIC_PREFIX + importName;
//         }
//         return importName;
//     }
// 
//     public String getFqcn() {
//         return importName;
//     }
// 
//     @Override
//     public String toString() {
//         return StringRepresentation.ofInstance(this)
//                 .add("import", importName)
//                 .add("line", line)
//                 .add("static", staticImport)
//                 .toString();
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(importName, line, staticImport);
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         return obj == this || obj instanceof ImportStatement
//                 && Objects.equals(this.line, ((ImportStatement) obj).line)
//                 && Objects.equals(this.staticImport, ((ImportStatement) obj).staticImport)
//                 && Objects.equals(this.importName, ((ImportStatement) obj).importName);
//     }
// }
// 
// Path: src/main/java/de/skuzzle/enforcer/restrictimports/util/Whitespaces.java
// public final class Whitespaces {
// 
//     private static final Pattern LEADING = Pattern.compile("^\\s+");
//     private static final Pattern TRAILING = Pattern.compile("\\s+$");
// 
//     /**
//      * Trims all leading and trailing whitespaces (regex pattern class <code>\s</code>)
//      *
//      * @param s The string to trim.
//      * @return The trimmed string.
//      */
//     public static final String trimAll(String s) {
//         final Matcher leadingMatcher = LEADING.matcher(s);
//         final Matcher trailingMatcher = TRAILING.matcher(s);
//         final boolean hasLeading = leadingMatcher.find();
//         final boolean hasTrailing = trailingMatcher.find();
//         if (!hasLeading && !hasTrailing) {
//             return s;
//         }
//         final int start = hasLeading ? leadingMatcher.end() : 0;
//         final int end = hasTrailing ? trailingMatcher.start() : s.length();
//         return s.substring(start, end);
//     }
// 
//     private Whitespaces() {
//         // hidden
//     }
// }


import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import de.skuzzle.enforcer.restrictimports.parser.ImportStatement;
import de.skuzzle.enforcer.restrictimports.util.Whitespaces;
package de.skuzzle.enforcer.restrictimports.parser.lang;



public class KotlinGroovyLanguageSupport implements LanguageSupport {

    private static final String STATIC_PREFIX = "static";
    private static final String IMPORT_STATEMENT = "import ";
    private static final String PACKAGE_STATEMENT = "package ";
    private static final Set<String> EXTENSIONS = Collections
            .unmodifiableSet(new HashSet<>(Arrays.asList("groovy", "kt")));

    @Override
    public Set<String> getSupportedFileExtensions() {
        return EXTENSIONS;
    }

    @Override
    public Optional<String> parsePackage(String line) {
        if (!isPackage(line)) {
            return Optional.empty();
        }

        return Optional.of(extractPackageName(line));
    }

    @Override
// Path: src/main/java/de/skuzzle/enforcer/restrictimports/parser/ImportStatement.java
// public final class ImportStatement {
// 
//     private static final String IMPORT_PREFIX = "import ";
//     private static final String STATIC_PREFIX = "static ";
//     private final String importName;
//     private final int line;
//     private final boolean staticImport;
// 
//     public ImportStatement(String importName, int line, boolean staticImport) {
//         Preconditions.checkArgument(importName != null && !importName.isEmpty(), "importName must not be empty");
//         Preconditions.checkArgument(!importName.startsWith(IMPORT_PREFIX),
//                 "importName should be the raw package name without 'import ' prefix but was: '%s'", importName);
//         Preconditions.checkArgument(!importName.startsWith(STATIC_PREFIX),
//                 "importName should be the raw package name without 'static ' prefix but was: '%s'", importName);
//         Preconditions.checkArgument(importName.trim().equals(importName),
//                 "importName has leading or trailing spaces: '%s'", importName);
//         Preconditions.checkArgument(line > 0, "line numbers should be 1-based and not start at 0");
// 
//         this.importName = importName;
//         this.line = line;
//         this.staticImport = staticImport;
//     }
// 
//     /**
//      * The physical line within the source file in which the import has occurred. Number
//      * is always 1-based!
//      *
//      * @return The line number of the matched imports.
//      */
//     public int getLine() {
//         return line;
//     }
// 
//     /**
//      * Returns the import name including the 'static ' prefix if this represents a static
//      * import.
//      *
//      * @return The full import name.
//      */
//     public String getImportName() {
//         if (staticImport) {
//             return STATIC_PREFIX + importName;
//         }
//         return importName;
//     }
// 
//     public String getFqcn() {
//         return importName;
//     }
// 
//     @Override
//     public String toString() {
//         return StringRepresentation.ofInstance(this)
//                 .add("import", importName)
//                 .add("line", line)
//                 .add("static", staticImport)
//                 .toString();
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(importName, line, staticImport);
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         return obj == this || obj instanceof ImportStatement
//                 && Objects.equals(this.line, ((ImportStatement) obj).line)
//                 && Objects.equals(this.staticImport, ((ImportStatement) obj).staticImport)
//                 && Objects.equals(this.importName, ((ImportStatement) obj).importName);
//     }
// }
// 
// Path: src/main/java/de/skuzzle/enforcer/restrictimports/util/Whitespaces.java
// public final class Whitespaces {
// 
//     private static final Pattern LEADING = Pattern.compile("^\\s+");
//     private static final Pattern TRAILING = Pattern.compile("\\s+$");
// 
//     /**
//      * Trims all leading and trailing whitespaces (regex pattern class <code>\s</code>)
//      *
//      * @param s The string to trim.
//      * @return The trimmed string.
//      */
//     public static final String trimAll(String s) {
//         final Matcher leadingMatcher = LEADING.matcher(s);
//         final Matcher trailingMatcher = TRAILING.matcher(s);
//         final boolean hasLeading = leadingMatcher.find();
//         final boolean hasTrailing = trailingMatcher.find();
//         if (!hasLeading && !hasTrailing) {
//             return s;
//         }
//         final int start = hasLeading ? leadingMatcher.end() : 0;
//         final int end = hasTrailing ? trailingMatcher.start() : s.length();
//         return s.substring(start, end);
//     }
// 
//     private Whitespaces() {
//         // hidden
//     }
// }


// Path: src/main/java/de/skuzzle/enforcer/restrictimports/parser/lang/KotlinGroovyLanguageSupport.java
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import de.skuzzle.enforcer.restrictimports.parser.ImportStatement;
import de.skuzzle.enforcer.restrictimports.util.Whitespaces;

package de.skuzzle.enforcer.restrictimports.parser.lang;



public class KotlinGroovyLanguageSupport implements LanguageSupport {

    private static final String STATIC_PREFIX = "static";
    private static final String IMPORT_STATEMENT = "import ";
    private static final String PACKAGE_STATEMENT = "package ";
    private static final Set<String> EXTENSIONS = Collections
            .unmodifiableSet(new HashSet<>(Arrays.asList("groovy", "kt")));

    @Override
    public Set<String> getSupportedFileExtensions() {
        return EXTENSIONS;
    }

    @Override
    public Optional<String> parsePackage(String line) {
        if (!isPackage(line)) {
            return Optional.empty();
        }

        return Optional.of(extractPackageName(line));
    }

    @Override
    public List<ImportStatement> parseImport(String line, int lineNumber) {