summaryrefslogtreecommitdiff
path: root/platform/util/src/com/intellij/openapi/util/registry/RegistryValue.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/util/src/com/intellij/openapi/util/registry/RegistryValue.java')
-rw-r--r--platform/util/src/com/intellij/openapi/util/registry/RegistryValue.java47
1 files changed, 22 insertions, 25 deletions
diff --git a/platform/util/src/com/intellij/openapi/util/registry/RegistryValue.java b/platform/util/src/com/intellij/openapi/util/registry/RegistryValue.java
index 6c89311457f4..ae3873b8744f 100644
--- a/platform/util/src/com/intellij/openapi/util/registry/RegistryValue.java
+++ b/platform/util/src/com/intellij/openapi/util/registry/RegistryValue.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * 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.
@@ -42,16 +42,18 @@ public class RegistryValue {
private Double myDoubleCachedValue;
private Boolean myBooleanCachedValue;
- RegistryValue(Registry registry, String key) {
+ RegistryValue(@NotNull Registry registry, @NotNull String key) {
myRegistry = registry;
myKey = key;
}
+ @NotNull
public String getKey() {
return myKey;
}
+ @NotNull
public String asString() {
final String value = get(myKey, null, true);
assert value != null : myKey;
@@ -97,6 +99,7 @@ public class RegistryValue {
return defaultValue;
}
+ @NotNull
public String getDescription() {
return get(myKey + ".description", "", false);
}
@@ -109,42 +112,36 @@ public class RegistryValue {
return !asString().equals(getBundleValue(myKey, false));
}
- private String get(String key, String defaultValue, boolean isValue) {
+ private String get(@NotNull String key, String defaultValue, boolean isValue) throws MissingResourceException {
if (isValue) {
if (myStringCachedValue == null) {
myStringCachedValue = _get(key, defaultValue, isValue);
- }
- if (isBoolean()) {
- myStringCachedValue = Boolean.valueOf(myStringCachedValue).toString();
+ if (isBoolean()) {
+ myStringCachedValue = Boolean.valueOf(myStringCachedValue).toString();
+ }
}
return myStringCachedValue;
}
- else {
- return _get(key, defaultValue, isValue);
- }
+ return _get(key, defaultValue, isValue);
}
- private String _get(String key, String defaultValue, boolean mustExistInBundle) {
+ private String _get(@NotNull String key, String defaultValue, boolean mustExistInBundle) throws MissingResourceException {
final String userValue = myRegistry.getUserProperties().get(key);
- if (userValue == null) {
- String systemProperty = System.getProperty(key);
- if (systemProperty != null) {
- return systemProperty;
- }
- final String bundleValue = getBundleValue(key, mustExistInBundle);
- if (bundleValue != null) {
- return bundleValue;
- }
- else {
- return defaultValue;
- }
- }
- else {
+ if (userValue != null) {
return userValue;
}
+ String systemProperty = System.getProperty(key);
+ if (systemProperty != null) {
+ return systemProperty;
+ }
+ final String bundleValue = getBundleValue(key, mustExistInBundle);
+ if (bundleValue != null) {
+ return bundleValue;
+ }
+ return defaultValue;
}
- private String getBundleValue(String key, boolean mustExist) {
+ private static String getBundleValue(@NotNull String key, boolean mustExist) throws MissingResourceException {
try {
return Registry.getBundle().getString(key);
}