Enum Class JStacheType

java.lang.Object
java.lang.Enum<JStacheType>
io.jstach.jstache.JStacheType
All Implemented Interfaces:
Serializable, Comparable<JStacheType>, Constable

public enum JStacheType extends Enum<JStacheType>
Tells the annotation processor what kind of code to generate namely whether to generate full fledged jstachio templates (default JSTACHIO) or zero dependency templates (STACHE).

JStachio will guarantee to generate the following methods for this specific major version (this will only change on major version changes):

Guaranteed Generated Methods
Type Method Description
JSTACHIO
STACHE
<T extends Model> void execute(T model, Appendable appendable) Executes model
JSTACHIO <T extends Model> void execute(T model, Appendable appendable, Formatter formatter, Escaper escaper) Executes model with supplied formatter and escaper
JSTACHIO
STACHE
Class<?> modelClass() Return the model class (root context class annotated with JStache) that generated this template.
JSTACHIO
STACHE
this() No arg constructor that will resolve the formatter and escaper based on configuration.
JSTACHIO
STACHE
this(Function<@Nullable Object,String> formatter, Function<String,String> escaper) Constructor that uses the supplied formatter and escaper for execute(T model, Appendable appendable).
JSTACHIO this(TemplateConfig templateConfig) Constructor that configures a JStachio template based on configuration.
JSTACHIO
STACHE
public static GENERATED_CLASS of() Similar to the no arg constructor but reuses a single static singleton.

Class that are generated with type JSTACHIO will implement io.jstach.jstachio.Template interface and thus all methods on that interface (and parent interfaces) will be generated if needed (ie no default method).
Author:
agentgt
See Also:
  • Enum Constant Details

    • UNSPECIFIED

      public static final JStacheType UNSPECIFIED
      This effectively means not set and to let other JStacheConfig determine the setting.
    • JSTACHIO

      public static final JStacheType JSTACHIO
      The default code generation which allows reflective access to templates and requires the jstachio runtime (io.jstach.jstachio).
    • STACHE

      public static final JStacheType STACHE
      Zero runtime dependency renderers are generated if this is selected. Code will not have a single reference to JStachio runtime interfaces.

      Because there is no reference to the JStachio runtime the escaper and formatter are inline implementations that passthrough the result of Object.toString() directly to the appendable. Just like JStachios default formatter a null variable will fail fast with a null pointer exception. If you need different escaping or formatting you will have to provide your own implementation!

      If all templates in a project are generated this way then you can and ideally should set:

      • The jstachio-annotation dependency as an optional dependency (e.g. in Maven <optional>true</optional>)
      • as well as set in your module-info requires static io.jstach.jstache.
      The above will minimize your deployed footprint and downstream dependencies will not transitively need jstachio. N.B if you go this route you will not be able to use jstachio runtime extensions.
      API Note
      if this is selected jstachio runtime extensions will not work for the generated renderers.
  • Method Details

    • values

      public static JStacheType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static JStacheType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null