Collection<Couple<TemplateResource>> () { final LinkedHashMap<String, Couple<TemplateResource>> resources = new LinkedHashMap<>(); for (TemplateResource resource : getAllTemplates()) { final String baseName = getTemplateBaseName(resource); TemplateResource eq = toEqualsName(baseName).equals(resource.getFileName()) ? resource : null; TemplateResource hc = toHashCodeName(baseName).equals(resource.getFileName()) ? resource : null; final Couple<TemplateResource> couple = resources.get(baseName); if (couple != null) { resources.put(baseName, Couple.of(couple.first != null ? couple.first : eq, couple.second != null ? couple.second : hc)); } else { resources.put(baseName, Couple.of(eq, hc)); } } return resources.values(); }