Remove StringUtils#join in favor of String#join (Java 8)

This commit is contained in:
ljacqu
2016-10-02 12:44:10 +02:00
parent e07c685d2a
commit 71ac86ff02
19 changed files with 27 additions and 181 deletions
@@ -5,7 +5,6 @@ import net.ricecode.similarity.StringSimilarityService;
import net.ricecode.similarity.StringSimilarityServiceImpl;
import java.io.File;
import java.util.Arrays;
/**
* Utility class for String operations.
@@ -69,44 +68,6 @@ public final class StringUtils {
return str == null || str.trim().isEmpty();
}
/**
* Join a list of elements into a single string with the specified delimiter.
*
* @param delimiter The delimiter to use
* @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) {
if (delimiter == null) {
delimiter = "";
}
StringBuilder sb = new StringBuilder();
for (String element : elements) {
if (!isEmpty(element)) {
// Add the separator if it isn't the first element
if (sb.length() > 0) {
sb.append(delimiter);
}
sb.append(element);
}
}
return sb.toString();
}
/**
* Join a list of elements into a single string with the specified delimiter.
*
* @param delimiter The delimiter to use
* @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, String... elements) {
return join(delimiter, Arrays.asList(elements));
}
/**
* Format the information from a Throwable as string, retaining the type and its message.
*
@@ -126,7 +87,7 @@ public final class StringUtils {
* @return The created path
*/
public static String makePath(String... elements) {
return join(File.separator, elements);
return String.join(File.separator, elements);
}
}