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

com.mashape.unirest.http.Headers Maven / Gradle / Ivy

There is a newer version: 1.0.9
Show newest version
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;
	}	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy