Package ch.grengine.sources
Class DirBasedSources.Builder
java.lang.Object
ch.grengine.sources.DirBasedSources.Builder
- Enclosing class:
- DirBasedSources
Builder for instances of
DirBasedSources.- Since:
- 1.0
- Author:
- Alain Stalder, Made in Switzerland.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longthe default latency (5000ms = five seconds). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()builds a new instance ofDirBasedSources.gets the compiler factory.getDir()gets the script file directory.gets the dir mode.longgets the latency in milliseconds.getName()gets the sources name.gets the script extensions.gets the source factory.setCompilerFactory(CompilerFactory compilerFactory) sets the compiler factory for compiling sources, default is a new instance ofDefaultGroovyCompilerFactory.setDirMode(DirMode dirMode) sets the dir mode, default is not to scan subdirectories.setLatencyMs(long latencyMs) sets the latency in milliseconds for checking if script files in the directory have changed, default isDEFAULT_LATENCY_MS.sets the sources name, default is the canonical file path, with fallback to the absolute file path.setScriptExtensions(String... scriptExtensions) sets the script extensions, default is only "groovy".setScriptExtensions(Set<String> scriptExtensions) sets the script extensions, default is only "groovy".setSourceFactory(SourceFactory sourceFactory) sets the source factory for creating sources from files, default is a new instance ofDefaultSourceFactory.
-
Field Details
-
DEFAULT_LATENCY_MS
public static final long DEFAULT_LATENCY_MSthe default latency (5000ms = five seconds).- Since:
- 1.0
- See Also:
-
-
Constructor Details
-
Builder
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
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
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
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
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
sets the compiler factory for compiling sources, default is a new instance ofDefaultGroovyCompilerFactory.- 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
sets the source factory for creating sources from files, default is a new instance ofDefaultSourceFactory.- 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
sets the latency in milliseconds for checking if script files in the directory have changed, default isDEFAULT_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
gets the script file directory.- Returns:
- script file directory
- Since:
- 1.0
-
getDirMode
gets the dir mode.- Returns:
- dir mode
- Since:
- 1.0
-
getScriptExtensions
gets the script extensions.- Returns:
- script extensions
- Since:
- 1.0
-
getName
gets the sources name.- Returns:
- sources name
- Since:
- 1.0
-
getCompilerFactory
gets the compiler factory.- Returns:
- compiler factory
- Since:
- 1.0
-
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
builds a new instance ofDirBasedSources.- Returns:
- new instance
- Since:
- 1.0
-