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

com.github.mati1979.play.soyplugin.render.RenderRequest Maven / Gradle / Ivy

There is a newer version: 0.1.18
Show newest version
package com.github.mati1979.play.soyplugin.render;

import java.util.Optional;
import com.google.template.soy.data.SoyMapData;
import com.google.template.soy.msgs.SoyMsgBundle;
import com.google.template.soy.tofu.SoyTofu;

/**
 * Created with IntelliJ IDEA.
 * User: mszczap
 * Date: 12.07.13
 * Time: 09:28
 *
 * An objects that wraps parameters needed to render a template
 */
public class RenderRequest {

    private final Optional compiledTemplates;

    private final String templateName;

    private final Optional soyModel;

    private final Optional globalRuntimeModel;

    private final Optional soyMsgBundle;

    private RenderRequest(final Builder builder) {
        this.compiledTemplates = builder.compiledTemplates;
        this.templateName = builder.templateName;
        this.globalRuntimeModel = builder.globalRuntimeModel;
        this.soyMsgBundle = builder.soyMsgBundle;
        this.soyModel = builder.soyModel;
    }

    public Optional getSoyModel() {
        return soyModel;
    }

    public Optional getGlobalRuntimeModel() {
        return globalRuntimeModel;
    }

    public Optional getSoyMsgBundle() {
        return soyMsgBundle;
    }

    public Optional getCompiledTemplates() {
        return compiledTemplates;
    }

    public String getTemplateName() {
        return templateName;
    }

    @Override
    public String toString() {
        return "RenderRequest{" +
                "compiledTemplates=" + compiledTemplates +
                ", templateName='" + templateName + '\'' +
                ", soyModel=" + soyModel +
                ", globalRuntimeModel=" + globalRuntimeModel +
                ", soyMsgBundle=" + soyMsgBundle +
                '}';
    }

    public static class Builder {

        private Optional compiledTemplates;
        private String templateName;

        private Optional soyModel;

        private Optional globalRuntimeModel = Optional.empty();
        private Optional soyMsgBundle = Optional.empty();

        public Builder compiledTemplates(final Optional compiledTemplates) {
            this.compiledTemplates = compiledTemplates;
            return this;
        }

        public Builder soyModel(final Optional soyModel) {
            this.soyModel = soyModel;

            return this;
        }

        public Builder templateName(final String templateName) {
            this.templateName = templateName;
            return this;
        }

        public Builder globalRuntimeModel(final Optional globalRuntimeModel) {
            this.globalRuntimeModel = globalRuntimeModel;
            return this;
        }

        public Builder soyMsgBundle(final Optional soyMsgBundle) {
            this.soyMsgBundle = soyMsgBundle;
            return this;
        }

        public RenderRequest build() {
            return new RenderRequest(this);
        }

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy