Class TemplateSourceResolver

java.lang.Object
com.pragma.archetype.infrastructure.adapter.out.template.TemplateSourceResolver

public class TemplateSourceResolver extends Object
Resolves the source from which templates should be loaded. Determines whether to use local filesystem or remote repository based on configuration. Resolution order: 1. Check for configured localPath in TemplateConfig 2. Auto-detect ../backend-architecture-design-archetype-generator-templates 3. Fall back to remote repository with branch support
  • Constructor Details

    • TemplateSourceResolver

      public TemplateSourceResolver(TemplateConfig config)
      Creates a resolver with the given template configuration.
      Parameters:
      config - template configuration
  • Method Details

    • resolveSource

      public TemplateSource resolveSource()
      Resolves the template source based on configuration and filesystem state.
      Returns:
      the resolved template source
      Throws:
      TemplateSourceResolver.TemplateSourceException - if configured local path does not exist
    • isLocalMode

      public boolean isLocalMode()
      Checks if the resolved source is local mode (configured or auto-detected).
      Returns:
      true if using local filesystem, false otherwise
    • isRemoteMode

      public boolean isRemoteMode()
      Checks if the resolved source is remote mode.
      Returns:
      true if using remote repository, false otherwise
    • getLocalPath

      public Path getLocalPath()
      Gets the resolved local path if in local mode.
      Returns:
      the local path, or null if in remote mode
    • getResolvedSource

      public TemplateSource getResolvedSource()
      Gets the resolved template source.
      Returns:
      the resolved source
    • validateSource

      public void validateSource()
      Validates that the resolved source is accessible. For local mode, checks that the path exists and is a directory. For remote mode, validates that repository URL and branch are configured.
      Throws:
      TemplateSourceResolver.TemplateSourceException - if validation fails
    • getSourceDescription

      public String getSourceDescription()
      Gets a description of the resolved source for logging.
      Returns:
      human-readable description of the template source