import java.util.regex.Matcher; import java.util.regex.Pattern; @Service public class EntityInfoService { // ... autres méthodes du service private EntityInfo parseEntityInfo(Path filePath) { try { String entityName = filePath.getFileName().toString().replace(".java", ""); Pattern attributePattern = Pattern.compile("\\s+private\\s+(\\S+)\\s+(\\w+);"); Map<String, String> attributesMap = Files.lines(filePath) .filter(line -> line.contains("private")) .map(line -> { Matcher matcher = attributePattern.matcher(line); if (matcher.find()) { String attributeType = matcher.group(1); String attributeName = matcher.group(2); return Map.entry(attributeName, attributeType); } return null; }) .filter(entry -> entry != null) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); return new EntityInfo(entityName, attributesMap); } catch (IOException e) { e.printStackTrace(); // Gérer l'exception de manière appropriée return new EntityInfo("", new HashMap<>()); } } }