class FreemarkerUtil {

    public static <T> T getAsObject(TemplateModel model, Class<T> type, T defaultValue) {
        try {
            T retValue = defaultValue;
            if (model != null) {
                @SuppressWarnings("unchecked")
                T value = (T) DeepUnwrap.unwrap(model);
                if (value != null) {
                    retValue = value;
                }
            }
            return retValue;
        } catch (TemplateModelException e) {
            throw new FreemarkerAutotagException("Cannot unwrap a model", e);
        }
    }

    private  FreemarkerUtil();

}