From 1f6370859be53ea8b078533678892f1548f4b72e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A1udio=20Gomes?= Date: Thu, 7 Mar 2024 16:08:12 -0300 Subject: [PATCH] impl. ordered listFolder --- .../clagomess/pirilampo/core/compilers/Compiler.java | 12 +++++++----- .../core/compilers/FolderToHTMLCompiler.java | 11 ++++------- .../core/compilers/FolderToPDFCompiler.java | 4 ++-- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/com/github/clagomess/pirilampo/core/compilers/Compiler.java b/core/src/main/java/com/github/clagomess/pirilampo/core/compilers/Compiler.java index f281c99..5f9c8cd 100644 --- a/core/src/main/java/com/github/clagomess/pirilampo/core/compilers/Compiler.java +++ b/core/src/main/java/com/github/clagomess/pirilampo/core/compilers/Compiler.java @@ -7,7 +7,10 @@ import java.io.*; import java.net.URL; import java.nio.charset.StandardCharsets; -import java.util.*; +import java.util.Arrays; +import java.util.LinkedHashSet; +import java.util.Set; +import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -23,16 +26,15 @@ public String getFeatureExtension(File f){ return matcher.find() ? matcher.group(0) : null; } - protected List listFolder(File curDir) throws Exception { - // @TODO: maibe ordered? - List buffer = new LinkedList<>(); + protected Set listFolder(File curDir) throws Exception { + Set buffer = new TreeSet<>(); listFolder(buffer, curDir); return buffer; } - private void listFolder(List buffer, File curDir) throws Exception { + private void listFolder(Set buffer, File curDir) throws Exception { File[] filesList = curDir.listFiles(); if(filesList == null) throw new Exception("*.features not found"); diff --git a/core/src/main/java/com/github/clagomess/pirilampo/core/compilers/FolderToHTMLCompiler.java b/core/src/main/java/com/github/clagomess/pirilampo/core/compilers/FolderToHTMLCompiler.java index 7b3c759..c48eaa7 100644 --- a/core/src/main/java/com/github/clagomess/pirilampo/core/compilers/FolderToHTMLCompiler.java +++ b/core/src/main/java/com/github/clagomess/pirilampo/core/compilers/FolderToHTMLCompiler.java @@ -1,5 +1,7 @@ package com.github.clagomess.pirilampo.core.compilers; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.github.clagomess.pirilampo.core.dto.FeatureIndexDto; import com.github.clagomess.pirilampo.core.dto.FeatureMasterDto; import com.github.clagomess.pirilampo.core.dto.FeatureMetadataDto; @@ -8,18 +10,13 @@ import com.github.clagomess.pirilampo.core.parsers.GherkinDocumentParser; import com.github.clagomess.pirilampo.core.parsers.ImageParser; import com.github.clagomess.pirilampo.core.parsers.MenuParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; import java.io.*; import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; import java.util.stream.Collectors; @Slf4j @@ -123,7 +120,7 @@ protected void buildIndex(PrintWriter out) throws JsonProcessingException { public void build() throws Exception { MenuParser menuParser = new MenuParser(parameters); - final List arquivos = listFolder(parameters.getProjectSource()); + Set arquivos = listFolder(parameters.getProjectSource()); if(arquivos.isEmpty()) return; try ( diff --git a/core/src/main/java/com/github/clagomess/pirilampo/core/compilers/FolderToPDFCompiler.java b/core/src/main/java/com/github/clagomess/pirilampo/core/compilers/FolderToPDFCompiler.java index eecbe13..5f727cc 100644 --- a/core/src/main/java/com/github/clagomess/pirilampo/core/compilers/FolderToPDFCompiler.java +++ b/core/src/main/java/com/github/clagomess/pirilampo/core/compilers/FolderToPDFCompiler.java @@ -9,8 +9,8 @@ import java.io.*; import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import java.util.List; import java.util.Objects; +import java.util.Set; @Slf4j @RequiredArgsConstructor @@ -18,7 +18,7 @@ public class FolderToPDFCompiler extends Compiler { private final ParametersDto parameters; public void build() throws Exception { - List arquivos = listFolder(parameters.getProjectSource()); + Set arquivos = listFolder(parameters.getProjectSource()); if(arquivos.isEmpty()) return; File outArtifact = getOutArtifact(parameters);