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

io.polaris.core.string.StringReplacerChain Maven / Gradle / Ivy

There is a newer version: 3.2.1
Show newest version
package io.polaris.core.string;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

/**
 * @author Qt
 * @since 1.8
 */
public class StringReplacerChain implements StringReplacer, Iterable {
	private final List replacers = new LinkedList<>();

	public StringReplacerChain(StringReplacer... args) {
		for (StringReplacer arg : args) {
			replacers.add(arg);
		}
	}

	public StringReplacerChain add(StringReplacer element) {
		replacers.add(element);
		return this;
	}

	@Override
	public Iterator iterator() {
		return replacers.iterator();
	}

	@Override
	public String replace(String s) {
		for (StringReplacer strReplacer : replacers) {
			s = strReplacer.replace(s);
		}
		return s;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy