de.invation.code.toval.misc.MapUtils Maven / Gradle / Ivy
package de.invation.code.toval.misc;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
public class MapUtils {
/**
* String for value separation.
* Used for generating String representations of collections.
*/
public static final char VALUE_MAPPING = '=';
/**
* String for value separation.
* Used for generating String representations of collections.
*/
public static final char VALUE_SEPARATION = ' ';
/**
* Default precision used for String representations of map elements
* having type Float or Double.
*/
public static final int DEFAULT_PRECISION = 2;
/**
* String representation for empty maps.
*/
public static final String EMPTY_MAP = "[]";
public static String toString(HashMap,?> map) {
return toString(map, DEFAULT_PRECISION, DEFAULT_PRECISION);
}
public static String toString(HashMap,?> map, int precision) {
return toString(map, precision, precision);
}
public static String toString(HashMap,?> map, int keyPrecision, int valuePrecision) {
if(map == null)
throw new NullPointerException();
if(map.isEmpty())
return EMPTY_MAP;
Vector © 2015 - 2025 Weber Informatics LLC | Privacy Policy