mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 10:45:23 +08:00
Added: Add getDefaultIfUnset() to DataUtils and update comment
This commit is contained in:
@@ -10,6 +10,8 @@ import java.io.Serializable;
|
|||||||
|
|
||||||
public class DataUtils {
|
public class DataUtils {
|
||||||
|
|
||||||
|
/** Max safe limit of data size to prevent TransactionTooLargeException when transferring data
|
||||||
|
* inside or to other apps via transactions. */
|
||||||
public static final int TRANSACTION_SIZE_LIMIT_IN_BYTES = 100 * 1024; // 100KB
|
public static final int TRANSACTION_SIZE_LIMIT_IN_BYTES = 100 * 1024; // 100KB
|
||||||
|
|
||||||
private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
|
private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
|
||||||
@@ -171,6 +173,17 @@ public class DataUtils {
|
|||||||
return (object == null) ? def : object;
|
return (object == null) ? def : object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the {@link String} itself if it is not {@code null} or empty, otherwise default.
|
||||||
|
*
|
||||||
|
* @param value The {@link String} to check.
|
||||||
|
* @param def The default {@link String}.
|
||||||
|
* @return Returns {@code value} if it is not {@code null} or empty, otherwise returns {@code def}.
|
||||||
|
*/
|
||||||
|
public static String getDefaultIfUnset(@Nullable String value, String def) {
|
||||||
|
return (value == null || value.isEmpty()) ? def : value;
|
||||||
|
}
|
||||||
|
|
||||||
/** Check if a string is null or empty. */
|
/** Check if a string is null or empty. */
|
||||||
public static boolean isNullOrEmpty(String string) {
|
public static boolean isNullOrEmpty(String string) {
|
||||||
return string == null || string.isEmpty();
|
return string == null || string.isEmpty();
|
||||||
|
Reference in New Issue
Block a user