-
Notifications
You must be signed in to change notification settings - Fork 3
MiscUtils
The MiscUtils
class in the software.bluelib.utils.math
package provides utility methods for various common operations. This utility class includes methods for validating email addresses, converting strings to integers with default values, calculating Levenshtein distance, and converting hexadecimal color codes to RGB values.
-
isValidEmail(String)
Checks if a string is a valid email address.boolean isValid = MiscUtils.isValidEmail("[email protected]");
-
stringToIntWithDefault(String, int)
Converts a string to an integer, returning a default value if the string is not a valid integer.int result = MiscUtils.stringToIntWithDefault("123", 0);
-
calculateLevenshteinDistance(String, String)
Calculates the Levenshtein distance between two strings.int distance = MiscUtils.calculateLevenshteinDistance("kitten", "sitting");
-
hexToRGB(String)
Converts a hexadecimal color code to an RGB array.int[] rgb = MiscUtils.hexToRGB("#FFFFFF");
- Error Handling: If an input is invalid (e.g., an invalid hex color code), the method throws an appropriate exception and logs an error message.
- Utility Design: This class cannot be instantiated, as it contains a private constructor and only static methods.
By using MiscUtils
, you can streamline common operations and improve the consistency of your utility methods across your mod.