Move static function useSafetyChecks() to Application.

This commit is contained in:
Kevin Ruland 2011-12-13 19:20:59 +00:00
parent d00c83c2e4
commit 6bd6e81f9b
3 changed files with 14 additions and 2 deletions

View File

@ -31,6 +31,17 @@ public final class Application {
setLogOutputLevel(LogLevel.DEBUG); setLogOutputLevel(LogLevel.DEBUG);
} }
/**
* Return whether to use additional safety code checks.
*/
public static boolean useSafetyChecks() {
// Currently default to false unless openrocket.debug.safetycheck is defined
String s = System.getProperty("openrocket.debug.safetycheck");
if (s != null && !(s.equalsIgnoreCase("false") || s.equalsIgnoreCase("off"))) {
return true;
}
return false;
}
/** /**
* Retrieve the logger to be used in logging. By default this returns * Retrieve the logger to be used in logging. By default this returns

View File

@ -10,7 +10,7 @@ import net.sf.openrocket.startup.Application;
* @author Sampo Niskanen <sampo.niskanen@iki.fi> * @author Sampo Niskanen <sampo.niskanen@iki.fi>
*/ */
public class Invalidator implements Invalidatable { public class Invalidator implements Invalidatable {
private static final boolean USE_CHECKS = Prefs.useSafetyChecks(); private static final boolean USE_CHECKS = Application.useSafetyChecks();
private static final LogHelper log = Application.getLogger(); private static final LogHelper log = Application.getLogger();

View File

@ -18,6 +18,7 @@ import net.sf.openrocket.startup.Application;
* @author Sampo Niskanen <sampo.niskanen@iki.fi> * @author Sampo Niskanen <sampo.niskanen@iki.fi>
*/ */
public abstract class SafetyMutex { public abstract class SafetyMutex {
private static final boolean USE_CHECKS = Application.useSafetyChecks();
private static final LogHelper log = Application.getLogger(); private static final LogHelper log = Application.getLogger();
@ -28,7 +29,7 @@ public abstract class SafetyMutex {
* @return a new instance of a safety mutex * @return a new instance of a safety mutex
*/ */
public static SafetyMutex newInstance() { public static SafetyMutex newInstance() {
if (Prefs.useSafetyChecks()) { if (USE_CHECKS) {
return new ConcreteSafetyMutex(); return new ConcreteSafetyMutex();
} else { } else {
return new BogusSafetyMutex(); return new BogusSafetyMutex();