package com.cooleshow.base.utils; import android.util.Pair; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Hashtable; import java.util.LinkedHashMap; import java.util.Map; import java.util.TreeMap; /** *
* author: blankj * blog : http://blankj.com * time : 2019/08/12 * desc : utils about map **/ public class MapUtils { private MapUtils() { throw new UnsupportedOperationException("u can't instantiate me..."); } /** * Returns a new read-only map with the specified contents, given as a list of pairs * where the first value is the key and the second is the value. * * @param pairs a list of pairs * @return a new read-only map with the specified contents */ @SafeVarargs public static
* Null returns true. * * @param map the map to check, may be null * @return true if empty or null */ public static boolean isEmpty(Map map) { return map == null || map.size() == 0; } /** * Null-safe check if the specified map is not empty. *
* Null returns false. * * @param map the map to check, may be null * @return true if non-null and non-empty */ public static boolean isNotEmpty(Map map) { return !isEmpty(map); } /** * Gets the size of the map specified. * * @param map The map. * @return the size of the map specified */ public static int size(Map map) { if (map == null) return 0; return map.size(); } /** * Executes the given closure on each element in the collection. *
* If the input collection or closure is null, there is no change made.
*
* @param map the map to get the input from, may be null
* @param closure the closure to perform, may be null
*/
public static
* If the input map or transformer is null, there is no change made.
*
* @param map the map to get the input from, may be null
* @param transformer the transformer to perform, may be null
*/
public static