public static boolean getBoolean(Map<String, Object> configuration, String key) { return getBoolean(configuration, key, false); }
public static int getInt(Map<String, Object> configuration, String key) { return getInt(configuration, key, 0); }
public static List<String> getList(Map<String, Object> configuration, String key) { return getList(configuration, key, null); }
String incompleteClasspathSeverity = getString(configuration, ERRORS_INCOMPLETE_CLASSPATH_SEVERITY_KEY, null); prefs.setIncompleteClasspathSeverity(Severity.fromString(incompleteClasspathSeverity, Severity.warning)); String updateBuildConfiguration = getString(configuration, CONFIGURATION_UPDATE_BUILD_CONFIGURATION_KEY, null); prefs.setUpdateBuildConfigurationStatus( FeatureStatus.fromString(updateBuildConfiguration, FeatureStatus.interactive)); boolean importGradleEnabled = getBoolean(configuration, IMPORT_GRADLE_ENABLED, true); prefs.setImportGradleEnabled(importGradleEnabled); boolean importMavenEnabled = getBoolean(configuration, IMPORT_MAVEN_ENABLED, true); prefs.setImportMavenEnabled(importMavenEnabled); boolean referenceCodelensEnabled = getBoolean(configuration, REFERENCES_CODE_LENS_ENABLED_KEY, true); prefs.setReferencesCodelensEnabled(referenceCodelensEnabled); boolean implementationCodeLensEnabled = getBoolean(configuration, IMPLEMENTATIONS_CODE_LENS_ENABLED_KEY, false); prefs.setImplementationCodelensEnabled(implementationCodeLensEnabled); boolean javaFormatEnabled = getBoolean(configuration, JAVA_FORMAT_ENABLED_KEY, true); prefs.setJavaFormatEnabled(javaFormatEnabled); boolean javaFormatOnTypeEnabled = getBoolean(configuration, JAVA_FORMAT_ON_TYPE_ENABLED_KEY, false); prefs.setJavaFormatOnTypeEnabled(javaFormatOnTypeEnabled); boolean javaSaveActionAutoOrganizeImportsEnabled = getBoolean(configuration, JAVA_SAVE_ACTIONS_ORGANIZE_IMPORTS_KEY, false); prefs.setJavaSaveActionAutoOrganizeImportsEnabled(javaSaveActionAutoOrganizeImportsEnabled); boolean signatureHelpEnabled = getBoolean(configuration, SIGNATURE_HELP_ENABLED_KEY, true); prefs.setSignatureHelpEnabled(signatureHelpEnabled); boolean renameEnabled = getBoolean(configuration, RENAME_ENABLED_KEY, true);
public static String getString(Map<String, Object> configuration, String key, String def) { Object val = getValue(configuration, key); if (val instanceof String) { return (String) val; } return def; }
public static String getString(Map<String, Object> configuration, String key) { return getString(configuration, key, null); }
public static boolean getBoolean(Map<String, Object> configuration, String key, boolean def) { Object val = getValue(configuration, key); if (val instanceof Boolean) { return ((Boolean) val).booleanValue(); } if (val instanceof String) { return Boolean.parseBoolean((String) val); } return def; }
public static int getInt(Map<String, Object> configuration, String key, int def) { Object val = getValue(configuration, key); if (val instanceof Number) { return ((Number) val).intValue(); } else if (val instanceof String) { try { return Integer.parseInt((String) val); } catch (NumberFormatException nfe) { JavaLanguageServerPlugin.logError(key + " value (" + val + ") is not an int, falling back on " + def); } } return def; }
public static List<String> getList(Map<String, Object> configuration, String key, List<String> def) { Object val = getValue(configuration, key); if (val instanceof String) { if (!((String) val).trim().startsWith("[")) { val = '[' + (String) val + ']'; } try { Gson gson = new Gson(); Type type = new TypeToken<List<String>>() { }.getType(); List<String> list = gson.fromJson((String) val, type); return list; } catch (JsonSyntaxException e) { JavaLanguageServerPlugin.logException(e.getMessage(), e); return def; } } if (val instanceof List) { List<String> ret; try { ret = (List<String>) val; return ret; } catch (Exception e) { JavaLanguageServerPlugin.logException(e.getMessage(), e); } } return def; }