Enum Class JStacheFlags.Flag

java.lang.Object
java.lang.Enum<JStacheFlags.Flag>
io.jstach.jstache.JStacheFlags.Flag
All Implemented Interfaces:
Serializable, Comparable<JStacheFlags.Flag>, Constable
Enclosing class:
JStacheFlags

public static enum JStacheFlags.Flag extends Enum<JStacheFlags.Flag>
Compiler flags. Besides setting with JStacheFlags the flags are also available as annotation processor options but are prefixed with "jstache." and lowercased

For example DEBUG would be: -Ajstache.debug=true/false

Author:
agentgt
API Note
SUBJECT TO CHANGE!
  • Enum Constant Details

    • UNSPECIFIED

      public static final JStacheFlags.Flag UNSPECIFIED
      Flag to indicate nothing is set. This is to differentiate a request to unset JStacheFlags.flags() flags vs ignore and cascade up. See JStacheConfig for config cascading.
      See Also:
    • DEBUG

      public static final JStacheFlags.Flag DEBUG
      This will produce additional logging that is sent to standard out while the annotation processor runs (not during runtime).
    • NO_INVERTED_BROKEN_CHAIN

      Per mustache spec dotted names can actually not exist at all for inverted sections. This flag disables that so that a compiler failure will happen if the fields are missing. For example assume "missing" is not present on "data" as in data has no field or method called "missing".
       {{^data.missing}}
       {{/data.missing}}
       
      Normally the above will compile just fine per the spec but this can lead to bugs. To not allow what the spec calls "dotted broken chains" you can use this flag.
    • NO_NULL_CHECKING

      public static final JStacheFlags.Flag NO_NULL_CHECKING
      EXPERIMENTAL: Normally falsey is either empty list, boolean false, or null. This flag disables null as a falsey check. For example when opening a section like:
      
       {{#myNonNull}}
       Hi!
       {{/myNonNull}}
        
      JStachio would produce code that checks if myNonNull is null as well as iterate if it is a list or check if true if it is a boolean.

      However null checking will still be done if JStachio can find a ElementType.TYPE_USE annotation with the Class.getSimpleName() of Nullable on the type that is being accessed as a section. This follows JSpecify rules but not other nullable annotations like SpotBugs that are not ElementType.TYPE_USE.

      Benefits

      The advantages of disabling null checking are:
      • Failing fast instead of just not rendering something which may make finding bugs easier.
      • Less generated code which maybe easier to read
      • Avoid warnings of superfluous null checking by static analysis tools
      • Possible slight improvement of performance

      Caveats

      JDK Bug
      Because of JDK bug: JDK-8225377 this nullable detection will only work if the type that is being checked is currently within the same compile boundary as the JStache model being analyzed!
      Manually checking for null
      If JStachio cannot detect that the type is nullable because it is not annotated or because of the aforementioned JDK bug then it will conclude that it can never be null and thus you will be unable to use section like conditions to check if is null. One workaround is to use a custom JStacheLambda to check for null.
      API Note
      This is currently experimental and a flag because of the JDK bug. In the future more comprehensive support will be put in JStacheConfig.
    • PRE_ENCODE_DISABLE

      If set the templates will NOT have pre-encoded bytes of the static parts of the template and the generated JStacheType.JSTACHIO code will not implement io.jstach.jstachio.Template.EncodedTemplate.
    • CONTEXT_SUPPORT_DISABLE

      Will always bind "@context" with a empty ContextNode.
  • Method Details

    • values

      public static JStacheFlags.Flag[] 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 JStacheFlags.Flag 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