This utility class is useful if you plan on implementing your own
or other integrations.
- API Note
- In order to use reflection in a modular setup one must
openpackages to the
Templateif possible otherwise falling back to a
TemplateInfobased on annotation metadata. This method is effectively calls
getTemplate(Class)first and if that fails possibly tries
getInfoByReflection(Class)based on config.
modelType- the models class (the one annotated with
JStacheand not the Templates class)
config- config used to determine whether or not to fallback
- the template info which might be a
Templateif the generated template was found.
Exception- if any reflection error happes or the template is not found
- API Note
- Callers can do an
instanceof Template tto see if a generated template was returned instead of the fallback.
getInfoByReflectionFinds template info by accessing JStache annotations through reflective lookup.
This allows you to lookup template meta data regardless of whether or not the annotation processor has generated code. This method is mainly used for fallback mechanisms and extensions.
Why might you need the reflective data instead of the static generated meta data? Well often times the annotation processor in a hot reload environment such as JRebel, JBoss modules, or Spring Reload has not generated the code from a JStache model and or it is not desired. This allows reflection based engines like JMustache to keep working even if code is not generated.
getTemplateFinds a template by reflection or an exception is thrown.