org.zodiac.template.base.impl.DefaultExtensionStrategy Maven / Gradle / Ivy
package org.zodiac.template.base.impl;
import org.zodiac.sdk.toolkit.util.AssertUtil;
/**
* 假如未指定模板名后缀,则使用默认后缀。
*
*/
public class DefaultExtensionStrategy implements TemplateSearchingStrategy {
private final String defaultExtension;
public DefaultExtensionStrategy(String defaultExtension) {
this.defaultExtension = AssertUtil.assertNotNull(defaultExtension, "defaultExtension");
}
public Object getKey(String templateName) {
return null;
}
public boolean findTemplate(TemplateMatcher matcher) {
if (matcher.getExtension() == null) {
matcher.setExtension(defaultExtension);
}
return matcher.findTemplate();
}
}