package jetbrains.mps.tool.environment;
/*Generated by MPS */
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.NotNull;
/**
* This class is to store the current environment (e.g used in tests, ant tasks etc.)
* Note that there is only one possible environment at the same moment
*/
public final class EnvironmentContainer {
private static Environment ourCurrent;
private EnvironmentContainer() {
}
@Nullable
public static synchronized Environment get() {
return ourCurrent;
}
/*package*/ static synchronized void setCurrent(@NotNull Environment env) {
if (EnvironmentContainer.ourCurrent != null) {
throw new IllegalStateException("Another environment is active: " + EnvironmentContainer.ourCurrent);
}
EnvironmentContainer.ourCurrent = env;
}
/*package*/ static synchronized void clear() {
if (ourCurrent == null) {
throw new IllegalStateException("No active environment currently");
}
EnvironmentContainer.ourCurrent = null;
}
}