All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.arextest.schedule.utils.MapUtils Maven / Gradle / Ivy

There is a newer version: 2.0.4
Show newest version
package com.arextest.schedule.utils;

import java.util.HashMap;
import java.util.Map;

public class MapUtils {

  public static  Map createMap(Object... keyValuePairs) {
    if (keyValuePairs.length % 2 != 0) {
      throw new IllegalArgumentException("Invalid number of arguments. Must be an even number.");
    }

    Map map = new HashMap<>();

    for (int i = 0; i < keyValuePairs.length; i += 2) {
      K key = (K) keyValuePairs[i];
      V value = (V) keyValuePairs[i + 1];
      map.put(key, value);
    }

    return map;
  }

  public static boolean isEmpty(Map map) {
    return !isNotEmpty(map);
  }

  public static boolean isNotEmpty(Map map) {
    return map != null && !map.isEmpty();
  }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy