Stuff from the common floobits workspace
Author: AuthMe-Team <AuthMeTeam@123NoEmail.com>
This commit is contained in:
@@ -12,17 +12,18 @@ import java.io.StringWriter;
|
||||
*/
|
||||
public class StringUtils {
|
||||
|
||||
public static final String newline = System.getProperty("line.separator");
|
||||
|
||||
/**
|
||||
* Get the difference of two strings.
|
||||
*
|
||||
* @param first First string
|
||||
* @param first First string
|
||||
* @param second Second string
|
||||
*
|
||||
* @return The difference value
|
||||
*/
|
||||
public static double getDifference(String first, String second) {
|
||||
// Make sure the strings are valid.
|
||||
if(first == null || second == null)
|
||||
if (first == null || second == null)
|
||||
return 1.0;
|
||||
|
||||
// Create a string similarity service instance, to allow comparison
|
||||
@@ -35,21 +36,20 @@ public class StringUtils {
|
||||
/**
|
||||
* Returns whether the given string contains any of the provided elements.
|
||||
*
|
||||
* @param str the string to analyze
|
||||
* @param str the string to analyze
|
||||
* @param pieces the items to check the string for
|
||||
*
|
||||
* @return true if the string contains at least one of the items
|
||||
*/
|
||||
public static boolean containsAny(String str, String... pieces) {
|
||||
if (str == null) {
|
||||
return false;
|
||||
}
|
||||
for (String piece : pieces) {
|
||||
if (piece != null && str.contains(piece)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
if (str == null) {
|
||||
return false;
|
||||
}
|
||||
for (String piece : pieces) {
|
||||
if (piece != null && str.contains(piece)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,7 +57,6 @@ public class StringUtils {
|
||||
* is trimmed, so this method also considers a string with whitespace as empty.
|
||||
*
|
||||
* @param str the string to verify
|
||||
*
|
||||
* @return true if the string is empty, false otherwise
|
||||
*/
|
||||
public static boolean isEmpty(String str) {
|
||||
@@ -68,8 +67,7 @@ public class StringUtils {
|
||||
* Joins a list of elements into a single string with the specified delimiter.
|
||||
*
|
||||
* @param delimiter the delimiter to use
|
||||
* @param elements the elements to join
|
||||
*
|
||||
* @param elements the elements to join
|
||||
* @return a new String that is composed of the elements separated by the delimiter
|
||||
*/
|
||||
public static String join(String delimiter, Iterable<String> elements) {
|
||||
@@ -91,7 +89,6 @@ public class StringUtils {
|
||||
* Get a full stack trace of an exception as a string.
|
||||
*
|
||||
* @param exception The exception.
|
||||
*
|
||||
* @return Stack trace as a string.
|
||||
*/
|
||||
public static String getStackTrace(Exception exception) {
|
||||
|
||||
Reference in New Issue
Block a user