Interface JStachioConfig

All Superinterfaces:
JStachioExtension

public non-sealed interface JStachioConfig extends JStachioExtension
Runtime Config Service.

While a majority of jstachio config is static and done at compile time some config like logging and disabling extensions is needed at runtime. Config and DI agnostic extensions should use this facility for simple key value based config.

The default resolved config uses System properties but can be replaced by implementing this extension.

Core runtime configuration properties for the default JStachio are:

This configuration is for runtime only and NOT static configuration needed for code generation.
Author:
agentgt
See Also:
  • Field Details

    • REFLECTION_TEMPLATE_DISABLE

      Config key to disable non service loader reflection based lookup of templates. If a custom JStachio is being used this configuration property maybe irrelevant.

      Valid values are true or false. The default is false.

      See Also:
    • SERVICELOADER_TEMPLATE_DISABLE

      Config key to disable service loader based lookup of templates. If a custom JStachio is being used this configuration property maybe irrelevant.

      Valid values are true or false. The default is false.

      See Also:
    • LOGGING_DISABLE

      static final String LOGGING_DISABLE
      Config key to disable logging. By default logging is enabled and will use the System.Logger. If a custom JStachioConfig is being used this configuration property maybe irrelevant.

      Valid values are true or false. The default is false.

      See Also:
  • Method Details

    • getProperty

      @Nullable String getProperty(String key)
      Gets a property from some config implementation.
      Parameters:
      key - the key to use to lookup
      Returns:
      if not found null.
    • getBoolean

      default boolean getBoolean(String key)
      Parameters:
      key - the property key
      Returns:
      only true if string is "true"
    • getBoolean

      default boolean getBoolean(String key, boolean fallback)
      Gets the property as a boolean and if no property value is found the fallback is used.
      Parameters:
      key - property key
      fallback - if property has no value this value is used.
      Returns:
      the parsed boolean or the fallback
    • requireProperty

      default String requireProperty(String key, String fallback)
      A NonNull friendly analog of System.getProperty(String, String) that will never return null unlike System.getProperty which is PolyNull.
      Parameters:
      key - checked if null and will NPE immediatly if it is
      fallback - used if the retrieved property is null
      Returns:
      property or fallback if property is not found (null).
      Throws:
      NullPointerException - if the fallback is null or if the key is null.
    • getLogger

      default System.Logger getLogger(String name)
      Gets a system logger if the property LOGGING_DISABLE is false. If the property is set to a true value a NOOP Logger that will not trigger initialization of the System System.Logger facilities will be returned. The NOOP logger is always disabled at every level and will not produce any output.
      Parameters:
      name - the name of the logger usually the class.
      Returns:
      the System logger.
      See Also:
    • noopLogger

      NOOP Logger that will not trigger initialization of the System System.Logger facilities. The NOOP logger is always disabled at every level and will not produce any output.

      Extensions might find this useful to set a nonnull Logger field like:

      
       private Logger logger = JStacheConfig.noopLogger();
       public void init(JStacheConfig config) {
           logger = config.getLogger(getClass().getName());
       }
        
      Returns:
      singleton instance of noop logger