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

com.sinch.sdk.core.utils.MapUtils Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
package com.sinch.sdk.core.utils;

import java.util.Map;
import java.util.Objects;
import java.util.TreeMap;

public class MapUtils {

  /**
   * @param headers Map to be transformed
   * @return A cloned map with case-insensitive comparator when looking for key value
   */
  public static  Map getCaseInsensitiveMap(Map headers) {

    // convert header keys to use case-insensitive map keys
    Map caseInsensitiveHeaders = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    // ensure no null key value
    headers.entrySet().removeIf(entry -> Objects.isNull(entry.getKey()));
    caseInsensitiveHeaders.putAll(headers);
    return caseInsensitiveHeaders;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy