org.snapscript.platform.generate.BridgeHolder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snap-all Show documentation
Show all versions of snap-all Show documentation
Dynamic scripting for the JVM
package org.snapscript.platform.generate;
import java.util.concurrent.Callable;
import org.snapscript.core.platform.Bridge;
public class BridgeHolder {
private volatile Callable source;
private volatile Bridge value;
public BridgeHolder(Callable source) {
this.source = source;
}
public Bridge getBridge() {
if(value == null) {
try {
value = source.call();
}catch(Exception e) {
throw new IllegalStateException("Could not create instance", e);
}
}
return value;
}
public void setBridge(Bridge value) {
this.value = value;
}
}