/*
 */

package com.voodoodyne.gstrap.lang;

import org.apache.commons.lang3.StringUtils;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

/**
 */
public class Strings2 {
	/**
	 * String must have some non-whitespace chars
	 */
	public static boolean notEmpty(String str) {
		return str != null && str.trim().length() > 0;
	}

	/**
	 * Returns a trimmed string or null if trimming produces an empty string.  Also produces null if input is null.
	 */
	public static String trimToNull(String value) {
		if (value == null)
			return null;

		value = value.trim();

		if (value.isEmpty())
			return null;
		else
			return value;
	}

	/** Chop to N chars */
	public static String chopTo(String str, int numberOfChars) {
		if (str.length() > numberOfChars)
			return str.substring(0, numberOfChars);
		else
			return str;
	}

	/** First letter captialized, everything else lowercase */
	public static String capitalize(final String input) {
		return StringUtils.capitalize(input.toLowerCase());
	}

	/** Break down into a set of fragments suitable for partial searching */
	public static Set<String> fragment(final String input) {
		if (StringUtils.isBlank(input))
			return Collections.emptySet();

		final Set<String> fragments = new HashSet<>();

		for (int i = 1; i <= input.length(); i++)
			fragments.add(input.substring(0, i));

		return fragments;
	}

}

@@ -161,16 +161,47 @@
 til.Set;
+%0Aimport java.util.StringJoiner;
 %0A%0A/**%0A *
@@ -1409,10 +1409,313 @@
 ts;%0A%09%7D%0A%0A
+%09/** Why oh why isn't the new stringjoiner API more functional? */%0A%09public static String join(final String%5B%5D strings, final String delimiter) %7B%0A%09%09final StringJoiner joiner = new StringJoiner(delimiter);%0A%0A%09%09for (final String string : strings) %7B%0A%09%09%09joiner.add(string);%0A%09%09%7D%0A%0A%09%09return joiner.toString();%0A%09%7D%0A
 %7D%0A

Add Strings2.join()