io.honeybadger.com.github.mustachejava.FallbackMustacheFactory Maven / Gradle / Ivy
package com.github.mustachejava;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
/**
* Mustache.java factory with a fallback mechanism for locating resources.
*
* (Some parts are based on DefaultMustacheFactory code that is Copyright 2010 RightTime, Inc.)
*
* @author gw0 [http://gw.tnode.com/] <[email protected]>
*/
public class FallbackMustacheFactory extends DefaultMustacheFactory {
/**
* List of fallback resource roots to search through.
*/
private Object[] resourceRoots;
/**
* Simple constructor for a fallback Mustache.java factory.
*
* @param resourceRoot normal resource root
* @param fallbackRoot fallback alternative root
*/
public FallbackMustacheFactory(String resourceRoot, String fallbackRoot) {
this(new Object[]{resourceRoot, fallbackRoot});
}
/**
* Simple constructor for a fallback Mustache.java factory.
*
* @param fileRoot normal resource root
* @param fallbackRoot fallback alternative root
*/
public FallbackMustacheFactory(File fileRoot, File fallbackRoot) {
this(new Object[]{fileRoot, fallbackRoot});
}
/**
* Generic constructor for a fallback Mustache.java factory.
*
* @param resourceRoots array of fallback resource roots as String or File
*/
@SuppressWarnings("StatementWithEmptyBody")
public FallbackMustacheFactory(Object... resourceRoots) {
super();
List