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

org.klojang.templates.SessionConfig Maven / Gradle / Ivy

The newest version!
package org.klojang.templates;

import static org.klojang.templates.AccessorRegistry.STANDARD_ACCESSORS;
import static org.klojang.templates.StringifierRegistry.STANDARD_STRINGIFIERS;

record SessionConfig(Template template,
    AccessorRegistry accessors,
    StringifierRegistry stringifiers) {

  SessionConfig(Template template) {
    this(template, STANDARD_ACCESSORS, STANDARD_STRINGIFIERS);
  }

  SessionConfig(Template template, StringifierRegistry stringifiers) {
    this(template, STANDARD_ACCESSORS, stringifiers);
  }

  SessionConfig(Template template, AccessorRegistry accessors) {
    this(template, accessors, STANDARD_STRINGIFIERS);
  }

  SoloSession newRenderSession() {
    return new SoloSession(this);
  }

  Accessor getAccessor(Object sourceData) {
    return accessors.getAccessor(sourceData, template);
  }

  SoloSession newChildSession(Template nested) {
    SessionConfig config = new SessionConfig(nested, accessors, stringifiers);
    return config.newRenderSession();
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy