TemplateResource (String selfSuffix, String oppositeSuffix, TemplateResource defaultTemplate) { final String fileName = defaultTemplate.getFileName(); if (fileName.endsWith(selfSuffix)) { return defaultTemplate; } final String equalsTemplateName = StringUtil.trimEnd(fileName, oppositeSuffix) + selfSuffix; for (TemplateResource resource : getAllTemplates()) { if (equalsTemplateName.equals(resource.getFileName())) { return resource; } } assert false : selfSuffix + " template for " + fileName + " not found"; return null; }