package me.loganb1max.minionsplus.util; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; public class Replacer { private Map replaceMap = new HashMap<>(); public static Replacer create() { return new Replacer(); } public Replacer add(final String key, final String value) { this.replaceMap.put(key, value); return this; } public String replace(String string) { for (Map.Entry entry : this.replaceMap.entrySet()) { string = string.replaceAll(entry.getKey(), entry.getValue()); } return string; } public List replace(List strings) { for (Map.Entry entry : this.replaceMap.entrySet()) { strings = strings.stream().map(s -> s.replaceAll(entry.getKey(), entry.getValue())).collect(Collectors.toList()); } return strings; } }