kz.greetgo.strconverter.simple.acceptors.NameValueList Maven / Gradle / Ivy
package kz.greetgo.strconverter.simple.acceptors;
import kz.greetgo.strconverter.simple.core.NameValue;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class NameValueList {
private final List names = new ArrayList<>();
private final Map values = new HashMap<>();
public void add(String name, Object value) {
names.add(name);
values.put(name, value);
}
public List list() {
return names.stream()
.map(name -> new NameValue(name, values.get(name)))
.collect(Collectors.toList());
}
public Object getValue(String name) {
return values.get(name);
}
}