io.virtdata.templates.StringCompositor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of virtdata-lib-realer Show documentation
Show all versions of virtdata-lib-realer Show documentation
With inspiration from other libraries
package io.virtdata.templates;
import io.virtdata.api.ValuesBinder;
import io.virtdata.core.Bindings;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
/**
* StringCompositor provides a way to build strings from a string template and provided values.
*
*
* The template is simply an array of string values, where odd indices represent token positions, and even indices represent
* literals. This version of the StringCompositor fetches data from the bindings only for the named fields in the template.
*
*/
public class StringCompositor implements ValuesBinder {
// protected static Pattern tokenPattern = Pattern.compile("(?(?([^{])+)?(?\\{(?[a-zA-Z0-9-_.]+)?\\})?)");
private String[] templateSegments;
private Function