
org.snapscript.core.ScopeMerger Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snap Show documentation
Show all versions of snap Show documentation
Dynamic scripting for the JVM
package org.snapscript.core;
public class ScopeMerger {
private final PathConverter converter;
private final Context context;
public ScopeMerger(Context context) {
this.converter = new FilePathConverter();
this.context = context;
}
public Scope merge(Model model, String name) {
Path path = converter.createPath(name);
if(path == null) {
throw new InternalStateException("Module '" +name +"' does not have a path");
}
return merge(model, name, path);
}
public Scope merge(Model model, String name, Path path) {
ModuleRegistry registry = context.getRegistry();
Module module = registry.addModule(name, path);
if(module == null) {
throw new InternalStateException("Module '" +name +"' not found");
}
return new ModelScope(model, module);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy