Class DirBasedSources.Builder

java.lang.Object
ch.grengine.sources.DirBasedSources.Builder
Enclosing class:
DirBasedSources

public static class DirBasedSources.Builder extends Object
Builder for instances of DirBasedSources.
Since:
1.0
Author:
Alain Stalder, Made in Switzerland.
  • Field Details

    • DEFAULT_LATENCY_MS

      public static final long DEFAULT_LATENCY_MS
      the default latency (5000ms = five seconds).
      Since:
      1.0
      See Also:
  • Constructor Details

    • Builder

      public Builder(File dir)
      constructor from script file directory.

      The given file is immediately converted to the canonical file, with fallback to the absolute file.

      Parameters:
      dir - script file directory
      Throws:
      NullPointerException - if the directory is null
      Since:
      1.0
  • Method Details

    • setDirMode

      public DirBasedSources.Builder setDirMode(DirMode dirMode)
      sets the dir mode, default is not to scan subdirectories.
      Parameters:
      dirMode - dir mode
      Returns:
      this, for chaining calls
      Throws:
      IllegalStateException - if the builder had already been used to build an instance
      Since:
      1.0
    • setScriptExtensions

      public DirBasedSources.Builder setScriptExtensions(Set<String> scriptExtensions)
      sets the script extensions, default is only "groovy".
      Parameters:
      scriptExtensions - script extensions
      Returns:
      this, for chaining calls
      Throws:
      IllegalStateException - if the builder had already been used to build an instance
      Since:
      1.0
    • setScriptExtensions

      public DirBasedSources.Builder setScriptExtensions(String... scriptExtensions)
      sets the script extensions, default is only "groovy".
      Parameters:
      scriptExtensions - script extensions
      Returns:
      this, for chaining calls
      Throws:
      IllegalStateException - if the builder had already been used to build an instance
      Since:
      1.0
    • setName

      public DirBasedSources.Builder setName(String name)
      sets the sources name, default is the canonical file path, with fallback to the absolute file path.
      Parameters:
      name - sources name
      Returns:
      this, for chaining calls
      Throws:
      IllegalStateException - if the builder had already been used to build an instance
      Since:
      1.0
    • setCompilerFactory

      public DirBasedSources.Builder setCompilerFactory(CompilerFactory compilerFactory)
      sets the compiler factory for compiling sources, default is a new instance of DefaultGroovyCompilerFactory.
      Parameters:
      compilerFactory - compiler factory
      Returns:
      this, for chaining calls
      Throws:
      IllegalStateException - if the builder had already been used to build an instance
      Since:
      1.0
    • setSourceFactory

      public DirBasedSources.Builder setSourceFactory(SourceFactory sourceFactory)
      sets the source factory for creating sources from files, default is a new instance of DefaultSourceFactory.
      Parameters:
      sourceFactory - source factory
      Returns:
      this, for chaining calls
      Throws:
      IllegalStateException - if the builder had already been used to build an instance
      Since:
      1.0
    • setLatencyMs

      public DirBasedSources.Builder setLatencyMs(long latencyMs)
      sets the latency in milliseconds for checking if script files in the directory have changed, default is DEFAULT_LATENCY_MS.
      Parameters:
      latencyMs - latency in milliseconds
      Returns:
      this, for chaining calls
      Throws:
      IllegalStateException - if the builder had already been used to build an instance
      Since:
      1.0
    • getDir

      public File getDir()
      gets the script file directory.
      Returns:
      script file directory
      Since:
      1.0
    • getDirMode

      public DirMode getDirMode()
      gets the dir mode.
      Returns:
      dir mode
      Since:
      1.0
    • getScriptExtensions

      public Set<String> getScriptExtensions()
      gets the script extensions.
      Returns:
      script extensions
      Since:
      1.0
    • getName

      public String getName()
      gets the sources name.
      Returns:
      sources name
      Since:
      1.0
    • getCompilerFactory

      public CompilerFactory getCompilerFactory()
      gets the compiler factory.
      Returns:
      compiler factory
      Since:
      1.0
    • getSourceFactory

      public SourceFactory getSourceFactory()
      gets the source factory.
      Returns:
      source factory
      Since:
      1.0
    • getLatencyMs

      public long getLatencyMs()
      gets the latency in milliseconds.
      Returns:
      latency in milliseconds
      Since:
      1.0
    • build

      public DirBasedSources build()
      builds a new instance of DirBasedSources.
      Returns:
      new instance
      Since:
      1.0