java.lang.Object
java.lang.Enum<Templates.TemplateLoadStrategy>
io.jstach.jstachio.spi.Templates.TemplateLoadStrategy
- All Implemented Interfaces:
Serializable
,Comparable<Templates.TemplateLoadStrategy>
,Constable
- Enclosing class:
- Templates
Strategy to load templates dynamically. These strategies expect the exact type
and not a super type!
- Author:
- agentgt
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionStrategy that will try no-arg constructorStrategy that will try theServiceLoader
with the SPI ofTemplateProvider
. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract boolean
isEnabled
(JStachioConfig config) Determine if the strategy is enabled.protected abstract <T> @Nullable Template<T>
load
(Class<T> clazz, ClassLoader classLoader, System.Logger logger) Load the template by this strategy.Returns the enum constant of this class with the specified name.static Templates.TemplateLoadStrategy[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
SERVICE_LOADER
Strategy that will try theServiceLoader
with the SPI ofTemplateProvider
. -
CONSTRUCTOR
Strategy that will try no-arg constructor
-
-
Method Details
-
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
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 nameNullPointerException
- if the argument is null
-
load
protected abstract <T> @Nullable Template<T> load(Class<T> clazz, ClassLoader classLoader, System.Logger logger) throws Exception Load the template by this strategy.- Type Parameters:
T
- model type.- Parameters:
clazz
- model type.classLoader
- classload which may more may not be used.logger
- used to log reflection warnings or other errors.- Returns:
- loaded template
- Throws:
Exception
- if an error happens while trying to load template.
-
isEnabled
Determine if the strategy is enabled.- Parameters:
config
- key value config- Returns:
- true if not disabled.
-