Better internal logic for DefaultComponentTemplateCompilerConfiguration.
This commit is contained in:
parent
9c21fb9a83
commit
8b7ffd64f8
@ -4,41 +4,45 @@ import groovy.lang.GroovyClassLoader;
|
||||
import org.codehaus.groovy.control.CompilePhase;
|
||||
import org.codehaus.groovy.control.CompilerConfiguration;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
public class DefaultComponentTemplateCompilerConfiguration implements ComponentTemplateCompilerConfiguration {
|
||||
|
||||
private GroovyClassLoader groovyClassLoader;
|
||||
private CompilerConfiguration groovyCompilerConfiguration;
|
||||
private CompilePhase toCompilePhase;
|
||||
|
||||
public DefaultComponentTemplateCompilerConfiguration() {
|
||||
this.groovyClassLoader = new GroovyClassLoader(Thread.currentThread().getContextClassLoader());
|
||||
this.groovyCompilerConfiguration = new CompilerConfiguration();
|
||||
this.toCompilePhase = CompilePhase.CLASS_GENERATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GroovyClassLoader getGroovyClassLoader() {
|
||||
return this.groovyClassLoader != null
|
||||
? this.groovyClassLoader
|
||||
: new GroovyClassLoader(this.getClass().getClassLoader());
|
||||
return this.groovyClassLoader;
|
||||
}
|
||||
|
||||
public void setGroovyClassLoader(GroovyClassLoader groovyClassLoader) {
|
||||
this.groovyClassLoader = groovyClassLoader;
|
||||
this.groovyClassLoader = requireNonNull(groovyClassLoader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompilerConfiguration getGroovyCompilerConfiguration() {
|
||||
return this.groovyCompilerConfiguration != null
|
||||
? this.groovyCompilerConfiguration
|
||||
: CompilerConfiguration.DEFAULT;
|
||||
return this.groovyCompilerConfiguration;
|
||||
}
|
||||
|
||||
public void setGroovyCompilerConfiguration(CompilerConfiguration groovyCompilerConfiguration) {
|
||||
this.groovyCompilerConfiguration = groovyCompilerConfiguration;
|
||||
this.groovyCompilerConfiguration = requireNonNull(groovyCompilerConfiguration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompilePhase getToCompilePhase() {
|
||||
return this.toCompilePhase != null ? this.toCompilePhase : CompilePhase.CLASS_GENERATION;
|
||||
return this.toCompilePhase;
|
||||
}
|
||||
|
||||
public void setToCompilePhase(CompilePhase toCompilePhase) {
|
||||
this.toCompilePhase = toCompilePhase;
|
||||
this.toCompilePhase = requireNonNull(toCompilePhase);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user