com.univocity.api.common
Class Utils

java.lang.Object
  extended by com.univocity.api.common.Utils

public class Utils
extends Object

A central place for utility methods.


Constructor Summary
Utils()
           
 
Method Summary
static
<V> Map.Entry<String,V>
getEntryCaseInsensitive(Map<String,V> map, String key)
          Returns the Map.Entry stored in a map by searching for a given String key case-insensitively.
static
<V> V
getValueCaseInsensitive(Map<String,V> map, String key)
          Returns the value stored in a map by searching for a given String key case-insensitively.
static String join(Iterable<?> values, String separator)
          Joins the String representation of all non-null values in a given collection into a String, with a given separator between each value.
static
<K,V extends Iterable>
Map<K,String>
joinValues(Map<K,V> map, String separator)
          Joins each collection of values in a given Map into their String representation, with a given separator between each value.
static
<V> void
putValueCaseInsensitive(Map<String,List<V>> map, String key, V value, boolean add)
          Adds a given value into a list of values of a map, where the key should be handled case-insensitively.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

join

public static final String join(Iterable<?> values,
                                String separator)
Joins the String representation of all non-null values in a given collection into a String, with a given separator between each value.

Parameters:
values - the values to be joined. Nulls are skipped.
separator - the separator to use between each value
Returns:
a String with all non-null values in the given collection.

joinValues

public static final <K,V extends Iterable> Map<K,String> joinValues(Map<K,V> map,
                                                                    String separator)
Joins each collection of values in a given Map into their String representation, with a given separator between each value.

Type Parameters:
K - the type of the key used in the given map
V - the type of the collection of values associated with each key of the map
Parameters:
map - a map containing collections as its values
separator - the separator to be used between each value
Returns:
the resulting map where each key of the given input map is associated with the String representation of all non-null values in the collection associated with the key.

getEntryCaseInsensitive

public static final <V> Map.Entry<String,V> getEntryCaseInsensitive(Map<String,V> map,
                                                                    String key)
Returns the Map.Entry stored in a map by searching for a given String key case-insensitively.

Type Parameters:
V - the type of values stored in the map
Parameters:
map - the map to search
key - the key to look for
Returns:
the Map.Entry associated with the given key, or null if not found.

getValueCaseInsensitive

public static final <V> V getValueCaseInsensitive(Map<String,V> map,
                                                  String key)
Returns the value stored in a map by searching for a given String key case-insensitively.

Type Parameters:
V - the type of values stored in the map
Parameters:
map - the map to search
key - the key to look for
Returns:
the value associated with the given key, or null if not found.

putValueCaseInsensitive

public static final <V> void putValueCaseInsensitive(Map<String,List<V>> map,
                                                     String key,
                                                     V value,
                                                     boolean add)
Adds a given value into a list of values of a map, where the key should be handled case-insensitively.

Type Parameters:
V - the type of the values stored in the map.
Parameters:
map - the map into which the value will be added
key - the key to look for
value - the value to add
add - a flag indicating whether the value should be added to the list of existing values, or if the list should be replaced by a new one containing only the given value.


Copyright © 2018 uniVocity Software Pty Ltd. All rights reserved.