org.mockserver.model.KeyToMultiValue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockserver-core Show documentation
Show all versions of mockserver-core Show documentation
Functionality used by all MockServer modules for matching and expectations
package org.mockserver.model;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @author jamesdbloom
*/
public class KeyToMultiValue extends ModelObject {
private final String name;
private final List values;
public KeyToMultiValue(String name, String... values) {
this(name, Arrays.asList(values));
}
public KeyToMultiValue(String name, List values) {
this.name = name;
if (values != null) {
this.values = values;
} else {
this.values = new ArrayList();
}
}
public static Multimap toMultiMap(List extends KeyToMultiValue> keyToMultiValues) {
Multimap headersMap = HashMultimap.create();
for (KeyToMultiValue keyToMultiValue : keyToMultiValues) {
for (String value : keyToMultiValue.getValues()) {
headersMap.put(keyToMultiValue.getName(), value);
}
}
return headersMap;
}
public static Multimap toMultiMap(KeyToMultiValue... keyToMultiValues) {
return toMultiMap(Arrays.asList(keyToMultiValues));
}
public String getName() {
return name;
}
public List getValues() {
return values;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy