Adds some strins methods in StringlistUtils.

This commit is contained in:
Christian P. MOMON 2015-05-23 02:55:38 +02:00
parent a4484fe3dc
commit d2d0990e05

View file

@ -18,6 +18,8 @@
*/
package fr.devinsy.util.strings;
import java.util.Collection;
/**
* The {@code StringUtils} class defines helper methods to string collection.
*
@ -163,6 +165,34 @@ public class StringListUtils
return result;
}
/**
*
* @param strings
* @return
*/
public static String toStringWithBracket(final Collection<String> strings)
{
String result;
if (strings == null)
{
result = null;
}
else
{
StringList buffer = new StringList();
buffer.append("[");
buffer.append(toStringWithCommas(strings));
buffer.append("]");
result = buffer.toString();
}
//
return result;
}
/**
*
* @param strings
@ -191,6 +221,26 @@ public class StringListUtils
return result;
}
/**
*
* @param strings
* @return
*/
public static String toStringWithBracketNotNull(final Collection<String> strings)
{
String result;
result = toStringWithBrackets(strings);
if (result == null)
{
result = "";
}
//
return result;
}
/**
*
* @param strings
@ -211,6 +261,35 @@ public class StringListUtils
return result;
}
/**
*
* @param source
* @return
*/
public static String toStringWithBrackets(final Collection<String> source)
{
String result;
if (source == null)
{
result = null;
}
else
{
StringList buffer = new StringList();
for (String string : source)
{
buffer.append("[").append(string).append("]");
}
result = buffer.toString();
}
//
return result;
}
/**
*
* @param source
@ -240,6 +319,28 @@ public class StringListUtils
return result;
}
/**
*
* @param source
* @return
*/
public static String toStringWithCommas(final Collection<String> source)
{
String result;
if (source == null)
{
result = null;
}
else
{
result = new StringList(source).toStringSeparatedBy(",");
}
//
return result;
}
/**
*
* @param source
@ -262,6 +363,28 @@ public class StringListUtils
return result;
}
/**
*
* @param source
* @return
*/
public static String toStringWithFrenchCommas(final Collection<String> source)
{
String result;
if (source == null)
{
result = null;
}
else
{
result = new StringList(source).toStringSeparatedBy(", ");
}
//
return result;
}
/**
*
* @param source