Skip to content

Commit

Permalink
Fixed: Use default values if extra-keys or extra-keys-style termux.pr…
Browse files Browse the repository at this point in the history
…operties values are empty
  • Loading branch information
agnostic-apollo committed Aug 23, 2021
1 parent 2a74d43 commit fbb9114
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,17 @@ public static <T> T getDefaultIfNull(@androidx.annotation.Nullable T object, @an
return (object == null) ? def : object;
}

/**
* Get the {@link String} object itself if it is not {@code null} or empty, otherwise default.
*
* @param object The {@link String} to check.
* @param def The default {@link String}.
* @return Returns {@code object} if it is not {@code null}, otherwise returns {@code def}.
*/
public static String getDefaultIfNullOrEmpty(@androidx.annotation.Nullable String object, @androidx.annotation.Nullable String def) {
return (object == null || object.isEmpty()) ? def : object;
}

/**
* Covert the {@link String} value to lowercase.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ public static String getDefaultWorkingDirectoryInternalPropertyValueFromValue(St
* @return Returns the internal value for value.
*/
public static String getExtraKeysInternalPropertyValueFromValue(String value) {
return SharedProperties.getDefaultIfNull(value, TermuxPropertyConstants.DEFAULT_IVALUE_EXTRA_KEYS);
return SharedProperties.getDefaultIfNullOrEmpty(value, TermuxPropertyConstants.DEFAULT_IVALUE_EXTRA_KEYS);
}

/**
Expand All @@ -433,7 +433,7 @@ public static String getExtraKeysInternalPropertyValueFromValue(String value) {
* @return Returns the internal value for value.
*/
public static String getExtraKeysStyleInternalPropertyValueFromValue(String value) {
return SharedProperties.getDefaultIfNull(value, TermuxPropertyConstants.DEFAULT_IVALUE_EXTRA_KEYS_STYLE);
return SharedProperties.getDefaultIfNullOrEmpty(value, TermuxPropertyConstants.DEFAULT_IVALUE_EXTRA_KEYS_STYLE);
}

/**
Expand Down

0 comments on commit fbb9114

Please sign in to comment.