freemarker.cache

## Class FirstMatchTemplateConfigurationFactory

- java.lang.Object
- - freemarker.cache.TemplateConfigurationFactory
  - - freemarker.cache.FirstMatchTemplateConfigurationFactory

    public class FirstMatchTemplateConfigurationFactory
    extends TemplateConfigurationFactory

Returns the first non-`null` result of the child factories, ignoring all further child factories. The child factories are called in the order as they were added.

### Constructor Summary

Constructors
Constructor and Description
`FirstMatchTemplateConfigurationFactory(TemplateConfigurationFactory... templateConfigurationFactories)`

### Method Summary

All Methods Instance Methods Concrete Methods
`FirstMatchTemplateConfigurationFactory` `allowNoMatch(boolean allow)` Same as `setAllowNoMatch(boolean)`, but return this object to support "fluent API" style.
`TemplateConfiguration` `get(String sourceName, Object templateSource)` Returns (maybe creates) the `TemplateConfiguration` for the given template source.
`boolean` `getAllowNoMatch()` Getter pair of `setAllowNoMatch(boolean)`.
`String` `getNoMatchErrorDetails()` Use this to specify the text added to the exception error message when there was no matching choice.
`FirstMatchTemplateConfigurationFactory` `noMatchErrorDetails(String message)` Same as `setNoMatchErrorDetails(String)`, but return this object to support "fluent API" style.
`void` `setAllowNoMatch(boolean allowNoMatch)` Use this to specify if having no matching choice is an error.
`protected void` `setConfigurationOfChildren(Configuration cfg)` Calls `TemplateConfiguration.setParentConfiguration(Configuration)` on each enclosed `TemplateConfiguration` and `TemplateConfigurationFactory.setConfiguration(Configuration)` on each enclosed `TemplateConfigurationFactory` objects.
`void` `setNoMatchErrorDetails(String noMatchErrorDetails)`

### Methods inherited from class freemarker.cache.TemplateConfigurationFactory

`getConfiguration, setConfiguration`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### FirstMatchTemplateConfigurationFactory

    public FirstMatchTemplateConfigurationFactory(TemplateConfigurationFactory... templateConfigurationFactories)

### Method Detail

#### get

    public TemplateConfiguration get(String sourceName,
                                     Object templateSource)
                              throws IOException,
                                     TemplateConfigurationFactoryException

Description copied from class: `TemplateConfigurationFactory`
Returns (maybe creates) the `TemplateConfiguration` for the given template source.

Specified by:
  `get` in class `TemplateConfigurationFactory`
Parameters:
  `sourceName` - The name (path) that was used for `TemplateLoader.findTemplateSource(String)`. See `Template.getSourceName()` for details.
  `templateSource` - The object returned by `TemplateLoader.findTemplateSource(String)`.
Returns:
  The `TemplateConfiguration` to apply, or `null` if the there's no `TemplateConfiguration` for this template source.
Throws:
  `IOException` - Typically, if there factory needs further I/O to find out more about the template source, but that fails.
  `TemplateConfigurationFactoryException` - If there's a problem that's specific to the factory logic.

#### getAllowNoMatch

    public boolean getAllowNoMatch()

Getter pair of `setAllowNoMatch(boolean)`.

#### setAllowNoMatch

    public void setAllowNoMatch(boolean allowNoMatch)

Use this to specify if having no matching choice is an error. The default is `false`, that is, it's an error if there was no matching choice.

See Also:
  `setNoMatchErrorDetails(String)`

#### getNoMatchErrorDetails

    public String getNoMatchErrorDetails()

Use this to specify the text added to the exception error message when there was no matching choice. The default is `null` (no error details).

See Also:
  `setAllowNoMatch(boolean)`

#### setNoMatchErrorDetails

    public void setNoMatchErrorDetails(String noMatchErrorDetails)

#### allowNoMatch

    public FirstMatchTemplateConfigurationFactory allowNoMatch(boolean allow)

Same as `setAllowNoMatch(boolean)`, but return this object to support "fluent API" style.

#### noMatchErrorDetails

    public FirstMatchTemplateConfigurationFactory noMatchErrorDetails(String message)

Same as `setNoMatchErrorDetails(String)`, but return this object to support "fluent API" style.

#### setConfigurationOfChildren

    protected void setConfigurationOfChildren(Configuration cfg)

Description copied from class: `TemplateConfigurationFactory`
Calls `TemplateConfiguration.setParentConfiguration(Configuration)` on each enclosed `TemplateConfiguration` and `TemplateConfigurationFactory.setConfiguration(Configuration)` on each enclosed `TemplateConfigurationFactory` objects. It only supposed to call these on the direct "children" of this object, not on the children of the children.

Specified by:
  `setConfigurationOfChildren` in class `TemplateConfigurationFactory`