<commit_before>package com.aimms.jenkins.testswarmplugin.extension;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

public class TestDirPathFiltering {
	private List<String> paths = new ArrayList<String>();
	private final String testDirSuffix;
	private final String sourceDir;
	 private final List<String> includeDirList ;
	 private final static String MODULE_DIVIDER_SYMBOL=",";

	public TestDirPathFiltering(List<String> subDirPaths, String sourceDir, String testFolderName,String  includedDirsInStrformat) {
		this.sourceDir = sourceDir;
		includeDirList = Arrays.asList(includedDirsInStrformat.split(MODULE_DIVIDER_SYMBOL));
		testDirSuffix = "/"+testFolderName;
		for (String subDirPath : subDirPaths) {
			filter(subDirPath);
		}
	}

	private void filter(String path) {
		path = path.replace(sourceDir, "");
		if (mustBeIncluded(path)) {
			if (path.endsWith(testDirSuffix)) {
				paths.add(path);

			} else if (path.contains(testDirSuffix + "/")) {
				paths.add(getProperPath(path));
			}
		}
	}

	private String getProperPath(String path) {
		// EOP = End Of Path
		int EOP = path.indexOf(testDirSuffix + "/") + testDirSuffix.length();
		path = path.substring(0, EOP).replace(sourceDir, "");
		return path;
	}

	public List<String> getFilteredPaths() {
		//Remove possible duplicate path-elements
		Set<String> pathSet = new LinkedHashSet<String>(paths);
		List<String> filteredPaths = new ArrayList<String>();
		filteredPaths.addAll(pathSet);
		return filteredPaths;
	}
	
	private boolean mustBeIncluded(String path) {
		String topDir = path.split("/")[0];
		if (includeDirList.contains(topDir) || includeDirList.contains(path.replace(testDirSuffix, "")) )
			return true;
		return false;
	}


}<commit_msg>refactored tgeh DirPath filtering class to use Set as an instance variable from teh beggining of the class instantiation<commit_after>package com.aimms.jenkins.testswarmplugin.extension;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

public class TestDirPathFiltering {
	private Set<String> paths = new LinkedHashSet<String>(); //Don't want duplicate path-elements
	private final String testDirSuffix;
	private final String sourceDir;
	 private final List<String> includeDirList ;
	 private final static String MODULE_DIVIDER_SYMBOL=",";

	public TestDirPathFiltering(List<String> subDirPaths, String sourceDir, String testFolderName,String  includedDirsInStrformat) {
		this.sourceDir = sourceDir;
		includeDirList = Arrays.asList(includedDirsInStrformat.split(MODULE_DIVIDER_SYMBOL));
		testDirSuffix = "/"+testFolderName;
		for (String subDirPath : subDirPaths) {
			filter(subDirPath);
		}
	}

	private void filter(String path) {
		path = path.replace(sourceDir, "");
		if (mustBeIncluded(path)) {
			if (path.endsWith(testDirSuffix)) {
				paths.add(path);

			} else if (path.contains(testDirSuffix + "/")) {
				paths.add(getProperPath(path));
			}
		}
	}

	private String getProperPath(String path) {
		// EOP = End Of Path
		int EOP = path.indexOf(testDirSuffix + "/") + testDirSuffix.length();
		path = path.substring(0, EOP).replace(sourceDir, "");
		return path;
	}

	public List<String> getFilteredPaths() {
		List<String> filteredPaths = new ArrayList<String>();
		filteredPaths.addAll(paths);
		return filteredPaths;
	}
	
	private boolean mustBeIncluded(String path) {
		String topDir = path.split("/")[0];
		if (includeDirList.contains(topDir) || includeDirList.contains(path.replace(testDirSuffix, "")) )
			return true;
		return false;
	}


}
{'fraction_non_alphanumeric': 0.1176954732510288, 'fraction_numerical': 0.0010973936899862826, 'mean_word_length': 5.096989966555184, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1569538', 'n_tokens_mistral': 1245, 'n_tokens_neox': 1155, 'n_words': 254}