com.mashape.unirest.http.Headers Maven / Gradle / Ivy
package com.mashape.unirest.http;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class Headers extends HashMap> {
private static final long serialVersionUID = 71310341388734766L;
public String getFirst(Object key) {
List list = get(key);
if (list != null && list.size() > 0) {
return list.get(0);
}
return null;
}
public Map getFlatHeaders(){
Map result = new HashMap();
for(Iterator i = this.keySet().iterator(); i.hasNext();) {
String key = i.next();
String value = getFirst(key);
result.put(key, value);
}
return result;
}
}