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

com.glispa.combo.MacroChainTemplateElement Maven / Gradle / Ivy

The newest version!
package com.glispa.combo;

import static java.util.Objects.requireNonNull;

/**
 * Internal implementation of {@link TemplateElement} for macro chain
 */
class MacroChainTemplateElement implements TemplateElement {

    private final Iterable> chain;

    MacroChainTemplateElement(Iterable> chain) {
        this.chain = chain;
    }

    @Override
    public String render(S state) {
        String result = "";
        for (Macro macro : chain) {
            result = requireNonNull(
                    macro.apply(result, state),
                    "null is not a valid macro result but it was return by " + macro.getClass().getName());
        }
        return result;
    }
}