<commit_before>package hu.elte.txtuml.export.cpp.structural;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import hu.elte.txtuml.export.cpp.templates.GenerationNames.UMLStdLibNames;
import hu.elte.txtuml.export.cpp.templates.GenerationTemplates;
import hu.elte.txtuml.export.cpp.templates.PrivateFunctionalTemplates;

public class DependencyExporter {
	private static Set<String> standardDependencies = new HashSet<>(Arrays.asList(UMLStdLibNames.ModelClassName,
			UMLStdLibNames.UMLInteger, UMLStdLibNames.UMLBoolean, UMLStdLibNames.UMLReal, UMLStdLibNames.UMLString));

	private Set<String> dependencies;
	private Set<String> headerOnlyDependency;
	private Set<String> cppOnlyDependency;
	private Set<String> headerOnlyIncludeDependency;

	public DependencyExporter() {
		dependencies = new HashSet<String>();
		headerOnlyDependency = new HashSet<>();
		cppOnlyDependency = new HashSet<>();
		headerOnlyIncludeDependency = new HashSet<>();
	}

	public String createDependencyCppIncludeCode(String className) {
		StringBuilder includes = new StringBuilder("");
		includes.append(PrivateFunctionalTemplates.include(className));
		dependencies.forEach(type -> {
			includes.append(PrivateFunctionalTemplates.include(type));
		});

		cppOnlyDependency.forEach(type -> {
			includes.append(PrivateFunctionalTemplates.include(type));
		});

		return includes.toString();
	}

	public String createDependencyHeaderIncludeCode(String preDeclNamespace) {
		StringBuilder preDeclerations = new StringBuilder();
		StringBuilder includes = new StringBuilder();

		dependencies.forEach(type -> {
			preDeclerations.append(GenerationTemplates.forwardDeclaration(type));
		});

		headerOnlyDependency.forEach(type -> {
			preDeclerations.append(GenerationTemplates.forwardDeclaration(type));
		});

		headerOnlyIncludeDependency.forEach(type -> {
			includes.append(PrivateFunctionalTemplates.include(type));
		});

		return includes.toString() + GenerationTemplates.putNamespace(preDeclerations.toString(), preDeclNamespace);

	}

	public void addDependency(String dependency) {
		if (!isSimpleDependency(dependency)) {
			dependencies.add(dependency);
		}

	}

	public void addDependencies(Collection<String> dependecies) {
		dependencies.forEach(this::addDependency);
	}

	public void addHeaderOnlyDependency(String dependency) {
		if (!dependencies.contains(dependency)) {
			headerOnlyDependency.add(dependency);
		}
	}

	public void addHeaderOnlyDependencies(Collection<String> dependencies) {
		dependencies.forEach(this::addHeaderOnlyDependency);
	}

	public void addHeaderOnlyIncludeDependency(String dependency) {
		headerOnlyIncludeDependency.add(dependency);
	}

	public void addHeaderOnlyIncludeDependencies(Collection<String> dependencies) {
		dependencies.forEach(this::addHeaderOnlyIncludeDependency);
	}

	public void addCppOnlyDependency(String dependency) {
		if (!dependencies.contains(dependency)) {
			cppOnlyDependency.add(dependency);<commit_msg>Fix typo<commit_after>package hu.elte.txtuml.export.cpp.structural;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import hu.elte.txtuml.export.cpp.templates.GenerationNames.UMLStdLibNames;
import hu.elte.txtuml.export.cpp.templates.GenerationTemplates;
import hu.elte.txtuml.export.cpp.templates.PrivateFunctionalTemplates;

public class DependencyExporter {
	private static Set<String> standardDependencies = new HashSet<>(Arrays.asList(UMLStdLibNames.ModelClassName,
			UMLStdLibNames.UMLInteger, UMLStdLibNames.UMLBoolean, UMLStdLibNames.UMLReal, UMLStdLibNames.UMLString));

	private Set<String> dependencies;
	private Set<String> headerOnlyDependency;
	private Set<String> cppOnlyDependency;
	private Set<String> headerOnlyIncludeDependency;

	public DependencyExporter() {
		dependencies = new HashSet<String>();
		headerOnlyDependency = new HashSet<>();
		cppOnlyDependency = new HashSet<>();
		headerOnlyIncludeDependency = new HashSet<>();
	}

	public String createDependencyCppIncludeCode(String className) {
		StringBuilder includes = new StringBuilder("");
		includes.append(PrivateFunctionalTemplates.include(className));
		dependencies.forEach(type -> {
			includes.append(PrivateFunctionalTemplates.include(type));
		});

		cppOnlyDependency.forEach(type -> {
			includes.append(PrivateFunctionalTemplates.include(type));
		});

		return includes.toString();
	}

	public String createDependencyHeaderIncludeCode(String preDeclNamespace) {
		StringBuilder preDeclerations = new StringBuilder();
		StringBuilder includes = new StringBuilder();

		dependencies.forEach(type -> {
			preDeclerations.append(GenerationTemplates.forwardDeclaration(type));
		});

		headerOnlyDependency.forEach(type -> {
			preDeclerations.append(GenerationTemplates.forwardDeclaration(type));
		});

		headerOnlyIncludeDependency.forEach(type -> {
			includes.append(PrivateFunctionalTemplates.include(type));
		});

		return includes.toString() + GenerationTemplates.putNamespace(preDeclerations.toString(), preDeclNamespace);

	}

	public void addDependency(String dependency) {
		if (!isSimpleDependency(dependency)) {
			dependencies.add(dependency);
		}

	}

	public void addDependencies(Collection<String> dependencies) {
		dependencies.forEach(this::addDependency);
	}

	public void addHeaderOnlyDependency(String dependency) {
		if (!dependencies.contains(dependency)) {
			headerOnlyDependency.add(dependency);
		}
	}

	public void addHeaderOnlyDependencies(Collection<String> dependencies) {
		dependencies.forEach(this::addHeaderOnlyDependency);
	}

	public void addHeaderOnlyIncludeDependency(String dependency) {
		headerOnlyIncludeDependency.add(dependency);
	}

	public void addHeaderOnlyIncludeDependencies(Collection<String> dependencies) {
		dependencies.forEach(this::addHeaderOnlyIncludeDependency);
	}

	public void addCppOnlyDependency(String dependency) {
		if (!dependencies.contains(dependency)) {
			cppOnlyDependency.add(dependency);
{'fraction_non_alphanumeric': 0.10391766268260293, 'fraction_numerical': 0.0, 'mean_word_length': 6.80440414507772, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 39, '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': '1379376', 'n_tokens_mistral': 1791, 'n_tokens_neox': 1624, 'n_words': 266}