Class PackageValidator
java.lang.Object
com.pragma.archetype.domain.service.PackageValidator
Domain service responsible for validating Java package names and structure.
Ensures package names follow Java naming conventions and align with folder
structure.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvalidateBasePackageConsistency(String packageName, String basePackage) Validates that all packages in a project start with the base package.validatePackageFolderAlignment(String packageName, Path filePath) Validates that package declaration matches the folder structure.validatePackageName(String packageName) Validates a Java package name according to Java naming conventions.
-
Constructor Details
-
PackageValidator
public PackageValidator()
-
-
Method Details
-
validatePackageName
Validates a Java package name according to Java naming conventions. Rules: - Must contain at least two segments separated by dots - Each segment must start with a lowercase letter - Segments can contain lowercase letters, numbers, and underscores - Cannot use Java reserved keywords- Parameters:
packageName- the package name to validate- Returns:
- ValidationResult with success status and any error messages
-
validatePackageFolderAlignment
Validates that package declaration matches the folder structure. Rules: - Package path must match folder structure - Each package segment must correspond to a folder- Parameters:
packageName- the package name (e.g., "com.example.service")filePath- the file path relative to source root (e.g., "com/example/service/MyClass.java")- Returns:
- ValidationResult with success status and any error messages
-
validateBasePackageConsistency
Validates that all packages in a project start with the base package. Rules: - All package names must start with the base package - Ensures consistent package structure across the project- Parameters:
packageName- the package name to validatebasePackage- the base package for the project- Returns:
- ValidationResult with success status and any error messages
-