@Test public void testDisablingClass() { assertTrue(Check.isEnabled(CheckTest.class)); System.setProperty("chk:" + CheckTest.class.getName(), "off"); assertFalse(Check.isEnabled(CheckTest.class)); }
public static boolean isEnabled(Class<?> cls) { String property; String path = cls.getName(); if ((property = System.getProperty(ENV_PREFIX + path)) == null) { property = System.getProperty(ENV_PREFIX + cls.getSimpleName()); while (property == null) { int idx = path.lastIndexOf("."); if (idx == -1) break; path = path.substring(0, idx); property = System.getProperty(ENV_PREFIX + path); } } boolean enabled = ENABLED_BY_DEFAULT; if (property != null) { if (property.equals("on")) enabled = true; else if (property.equals("off")) enabled = false; else throw new RuntimeException(getErrorMessage(property)); } logger.trace("Check is " + (enabled ? "ON" : "OFF") + " for class {}", cls); return enabled; }
Check { public static boolean isEnabled(Class<?> cls) { String property; String path = cls.getName(); if ((property = System.getProperty(ENV_PREFIX + path)) == null) { property = System.getProperty(ENV_PREFIX + cls.getSimpleName()); while (property == null) { int idx = path.lastIndexOf("."); if (idx == -1) break; path = path.substring(0, idx); property = System.getProperty(ENV_PREFIX + path); } } boolean enabled = ENABLED_BY_DEFAULT; if (property != null) { if (property.equals("on")) enabled = true; else if (property.equals("off")) enabled = false; else throw new RuntimeException(getErrorMessage(property)); } logger.trace("Check is " + (enabled ? "ON" : "OFF") + " for class {}", cls); return enabled; } }
Check { public static boolean isEnabled(Class<?> cls) { String property; String path = cls.getName(); if ((property = System.getProperty(ENV_PREFIX + path)) == null) { property = System.getProperty(ENV_PREFIX + cls.getSimpleName()); while (property == null) { int idx = path.lastIndexOf("."); if (idx == -1) break; path = path.substring(0, idx); property = System.getProperty(ENV_PREFIX + path); } } boolean enabled = ENABLED_BY_DEFAULT; if (property != null) { if (property.equals("on")) enabled = true; else if (property.equals("off")) enabled = false; else throw new RuntimeException(getErrorMessage(property)); } logger.trace("Check is " + (enabled ? "ON" : "OFF") + " for class {}", cls); return enabled; }  }
Check { public static boolean isEnabled(Class<?> cls) { String property; String path = cls.getName(); if ((property = System.getProperty(ENV_PREFIX + path)) == null) { property = System.getProperty(ENV_PREFIX + cls.getSimpleName()); while (property == null) { int idx = path.lastIndexOf("."); if (idx == -1) break; path = path.substring(0, idx); property = System.getProperty(ENV_PREFIX + path); } } boolean enabled = ENABLED_BY_DEFAULT; if (property != null) { if (property.equals("on")) enabled = true; else if (property.equals("off")) enabled = false; else throw new RuntimeException(getErrorMessage(property)); } logger.trace("Check is " + (enabled ? "ON" : "OFF") + " for class {}", cls); return enabled; }  static boolean isEnabled(Class<?> cls); }
Check { public static boolean isEnabled(Class<?> cls) { String property; String path = cls.getName(); if ((property = System.getProperty(ENV_PREFIX + path)) == null) { property = System.getProperty(ENV_PREFIX + cls.getSimpleName()); while (property == null) { int idx = path.lastIndexOf("."); if (idx == -1) break; path = path.substring(0, idx); property = System.getProperty(ENV_PREFIX + path); } } boolean enabled = ENABLED_BY_DEFAULT; if (property != null) { if (property.equals("on")) enabled = true; else if (property.equals("off")) enabled = false; else throw new RuntimeException(getErrorMessage(property)); } logger.trace("Check is " + (enabled ? "ON" : "OFF") + " for class {}", cls); return enabled; }  static boolean isEnabled(Class<?> cls);  }