/** * Boilerplate method for {@code asBoolean(false)} * * @return <tt>true</tt> if the wrapped value is <tt>true</tt> * or if the string representation of it is {@code "true"}. Returns <tt>false</tt> otherwise, * especially if the wrapped value is <tt>null</tt> */ public boolean asBoolean() { return asBoolean(false); }
/** * Creates a new setup for the given mode and class loader. * * @param mode the mode to run the framework in * @param loader the class loader used for component discovery */ public Setup(Mode mode, ClassLoader loader) { this.mode = mode; this.loader = loader; logToConsole = mode != Mode.PROD || getProperty("console").asBoolean(false); logToFile = mode == Mode.PROD && !getProperty("disableLogfile").asBoolean(false); }
@Override public Object transformValue(Value value) { return value.asBoolean(NLS.parseMachineString(Boolean.class, defaultValue)); }
@Override protected Object transformFromDatasource(Class<? extends BaseMapper<?, ?, ?>> mapperType, Value data) { Object object = data.get(); if (object instanceof Boolean) { return object; } if (data.is(String.class) ) { return data.asBoolean(); } if (object == null) { if (field.getType().isPrimitive()) { return false; } else { return null; } } return ((Integer) object) != 0; }
private Optional<Database> determineSecondary(Extension ext) { if (!ext.get(KEY_SECONDARY_ENABLED).asBoolean()) { return Optional.empty(); } return Optional.ofNullable(dbs.get(ext.get(KEY_SECONDARY_DATABASE).asString())); }
/** * Creates and starts a new setup based on system properties. * <p> * Essentially this is <tt>debug</tt> which switches from PROD to DEV and <tt>console</tt> which enables * log output to the console even if running in PROD mode. * * @param loader the class loader to use */ public static void createAndStartEnvironment(ClassLoader loader) { Sirius.start(new Setup(getProperty("debug").asBoolean(false) ? Mode.DEV : Mode.PROD, loader)); }
private static void setupFrameworks() { Config frameworkConfig = config.getConfig("sirius.frameworks"); Map<String, Boolean> frameworkStatus = Maps.newHashMap(); int total = 0; int numEnabled = 0; LOG.DEBUG_INFO("Scanning framework status (sirius.frameworks):"); for (Map.Entry<String, com.typesafe.config.ConfigValue> entry : frameworkConfig.entrySet()) { String framework = entry.getKey(); try { boolean enabled = Value.of(entry.getValue().unwrapped()).asBoolean(false); frameworkStatus.put(framework, enabled); total++; numEnabled += enabled ? 1 : 0; LOG.DEBUG_INFO(Strings.apply(" * %s: %b", framework, enabled)); } catch (Exception e) { Exceptions.ignore(e); LOG.WARN("Cannot convert status '%s' of framework '%s' to a boolean! Framework will be disabled.", entry.getValue().render(), framework); frameworkStatus.put(framework, false); } } LOG.INFO("Enabled %d of %d frameworks...", numEnabled, total); // Although customizations are loaded in setupConfiguration, we output the status here, // as this seems more intiutive for the customer (the poor guy reading the logs...) LOG.INFO("Active Customizations: %s", customizations); frameworks = frameworkStatus; }
try { Extension ext = Sirius.getSettings().getExtension(EXTENSION_MIXING_JDBC, target.getKey()); if (databases.containsKey(target.getKey()) && ext.get("updateSchema").asBoolean()) { SchemaTool tool = new SchemaTool(target.getKey(), globalContext.findPart(ext.get("dialect").asString(),