mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
[platform] inlines a simple utility method
(Boolean.parseBoolean() never throws an exception)
This commit is contained in:
@@ -280,8 +280,8 @@ public class RemoteCredentialsHolder implements MutableRemoteCredentials {
|
||||
setSerializedPassword(element.getAttributeValue(PASSWORD));
|
||||
setPrivateKeyFile(StringUtil.nullize(element.getAttributeValue(PRIVATE_KEY_FILE)));
|
||||
setSerializedPassphrase(element.getAttributeValue(PASSPHRASE));
|
||||
boolean useKeyPair = StringUtil.parseBoolean(element.getAttributeValue(USE_KEY_PAIR), false);
|
||||
boolean useAuthAgent = StringUtil.parseBoolean(element.getAttributeValue(USE_AUTH_AGENT), false);
|
||||
boolean useKeyPair = Boolean.parseBoolean(element.getAttributeValue(USE_KEY_PAIR));
|
||||
boolean useAuthAgent = Boolean.parseBoolean(element.getAttributeValue(USE_AUTH_AGENT));
|
||||
if (useKeyPair) {
|
||||
myAuthType = AuthType.KEY_PAIR;
|
||||
}
|
||||
@@ -317,7 +317,7 @@ public class RemoteCredentialsHolder implements MutableRemoteCredentials {
|
||||
}
|
||||
}
|
||||
|
||||
boolean isAnonymous = StringUtil.parseBoolean(element.getAttributeValue(ANONYMOUS), false);
|
||||
boolean isAnonymous = Boolean.parseBoolean(element.getAttributeValue(ANONYMOUS));
|
||||
if (isAnonymous) {
|
||||
setSerializedUserName("anonymous");
|
||||
setSerializedPassword("user@example.com");
|
||||
|
||||
@@ -180,9 +180,9 @@ public class RemoteSdkPropertiesHolder implements RemoteSdkProperties {
|
||||
|
||||
setRemoteRoots(JDOMExternalizer.loadStringsList(element, REMOTE_ROOTS, REMOTE_PATH));
|
||||
|
||||
setInitialized(StringUtil.parseBoolean(element.getAttributeValue(INITIALIZED), true));
|
||||
setInitialized(Boolean.parseBoolean(element.getAttributeValue(INITIALIZED)));
|
||||
|
||||
setValid(StringUtil.parseBoolean(element.getAttributeValue(VALID), true));
|
||||
setValid(Boolean.parseBoolean(element.getAttributeValue(VALID)));
|
||||
|
||||
setPathMappings(PathMappingSettings.readExternal(element));
|
||||
}
|
||||
|
||||
@@ -1,22 +1,7 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.execution.rmi.ssl;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.openapi.util.text.StringUtilRt;
|
||||
import com.intellij.security.CompositeX509TrustManager;
|
||||
import com.intellij.util.containers.ContainerUtilRt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -50,7 +35,7 @@ public class SslSocketFactory extends SSLSocketFactory {
|
||||
String caCertPath = System.getProperty(SSL_CA_CERT_PATH);
|
||||
String clientCertPath = System.getProperty(SSL_CLIENT_CERT_PATH);
|
||||
String clientKeyPath = System.getProperty(SSL_CLIENT_KEY_PATH);
|
||||
boolean trustEverybody = StringUtilRt.parseBoolean(System.getProperty(SSL_TRUST_EVERYBODY), false);
|
||||
boolean trustEverybody = Boolean.parseBoolean(System.getProperty(SSL_TRUST_EVERYBODY));
|
||||
|
||||
tms = trustEverybody ? new TrustManager[]{new MyTrustEverybodyManager()} :
|
||||
caCertPath == null ? new TrustManager[]{} : createTrustManagers(caCertPath);
|
||||
|
||||
@@ -206,16 +206,6 @@ public class StringUtilRt {
|
||||
}
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
public static boolean parseBoolean(String string, boolean defaultValue) {
|
||||
try {
|
||||
return Boolean.parseBoolean(string);
|
||||
}
|
||||
catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
static <E extends Enum<E>> E parseEnum(@NotNull String string, E defaultValue, @NotNull Class<E> clazz) {
|
||||
try {
|
||||
|
||||
@@ -3058,11 +3058,6 @@ public class StringUtil extends StringUtilRt {
|
||||
return StringUtilRt.parseDouble(string, defaultValue);
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
public static boolean parseBoolean(String string, final boolean defaultValue) {
|
||||
return StringUtilRt.parseBoolean(string, defaultValue);
|
||||
}
|
||||
|
||||
@Contract(pure = true)
|
||||
public static <E extends Enum<E>> E parseEnum(@NotNull String string, E defaultValue, @NotNull Class<E> clazz) {
|
||||
return StringUtilRt.parseEnum(string, defaultValue, clazz);
|
||||
|
||||
+4
-19
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy.lang.psi.typeEnhancers;
|
||||
|
||||
import com.intellij.openapi.util.Couple;
|
||||
@@ -90,7 +76,7 @@ public class MapEntryOrKeyValueHintProcessor extends SignatureHintProcessor {
|
||||
}
|
||||
|
||||
if (options.length == 1) {
|
||||
return StringUtilRt.parseBoolean(options[0], false);
|
||||
return Boolean.parseBoolean(options[0]);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -100,9 +86,8 @@ public class MapEntryOrKeyValueHintProcessor extends SignatureHintProcessor {
|
||||
Couple<String> pair = parseValue(value);
|
||||
if (pair == null) return null;
|
||||
|
||||
Boolean parsedValue = StringUtilRt.parseBoolean(pair.getSecond(), false);
|
||||
if ("index".equals(pair.getFirst())) {
|
||||
return parsedValue;
|
||||
return Boolean.valueOf(pair.getSecond());
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -130,4 +115,4 @@ public class MapEntryOrKeyValueHintProcessor extends SignatureHintProcessor {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.spellchecker.settings;
|
||||
|
||||
import com.intellij.openapi.components.*;
|
||||
@@ -189,8 +189,7 @@ public class SpellCheckerSettings implements PersistentStateComponent<Element> {
|
||||
myCorrectionsLimit = parseInt(element.getAttributeValue(CORRECTIONS_MAX_LIMIT), DEFAULT_MAX_VALUE);
|
||||
myDictionaryToSave = notNullize(element.getAttributeValue(DICTIONARY_TO_SAVE_ATTR_NAME), DEFAULT_DICTIONARY_TO_SAVE);
|
||||
myUseSingleDictionaryToSave =
|
||||
parseBoolean(notNullize(element.getAttributeValue(USE_SINGLE_DICT_ATTR_NAME), String.valueOf(DEFAULT_USE_SINGLE_DICT)),
|
||||
DEFAULT_USE_SINGLE_DICT);
|
||||
Boolean.parseBoolean(notNullize(element.getAttributeValue(USE_SINGLE_DICT_ATTR_NAME), String.valueOf(DEFAULT_USE_SINGLE_DICT)));
|
||||
}
|
||||
catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user