public final class Converters extends Object
Modifier and Type | Method and Description |
---|---|
static String |
joinArray(Object array,
String separator)
Joins all elements of the given array to a single string, separated by the given separator.
|
static <E> String |
joinCollection(Collection<E> collection,
String separator)
Joins all elements of the given collection to a single string, separated by the given separator.
|
static <K,V> String |
joinMap(Map<K,V> map,
String pairSeparator,
String entrySeparator)
Joins all elements of the given map to a single string, separated by the given key-value pair separator and
entry separator.
|
static <K,V> List<Map.Entry<K,V>> |
mapToList(Map<K,V> map)
Converts a
Map<K, V> to a List<Map.Entry<K, V>> . |
static String |
printStackTrace(Throwable exception)
Print the stack trace of the given exception.
|
static <E> List<E> |
setToList(Set<E> set)
Converts a
Set<E> to a List<E> . |
public static <E> List<E> setToList(Set<E> set)
Set<E>
to a List<E>
. Useful when you want to iterate over a
Set
in for example <ui:repeat>
.set
- The set to be converted to list of its entries.public static <K,V> List<Map.Entry<K,V>> mapToList(Map<K,V> map)
Map<K, V>
to a List<Map.Entry<K, V>>
. Useful when you want
to iterate over a Map
in for example <ui:repeat>
. Each of the entries has the
usual getKey()
and getValue()
methods.map
- The map to be converted to list of its entries.public static String joinArray(Object array, String separator)
array
- The array to be joined.separator
- The separator to be used. If null, then it defaults to empty string.IllegalArgumentException
- When the given array is not an array at all.public static <E> String joinCollection(Collection<E> collection, String separator)
collection
- The collection to be joined.separator
- The separator to be used. If null, then it defaults to empty string.public static <K,V> String joinMap(Map<K,V> map, String pairSeparator, String entrySeparator)
map
- The map to be joined.pairSeparator
- The key-value pair separator to be used. If null, then it defaults to empty string.entrySeparator
- The entry separator to be used. If null, then it defaults to empty string.