From 6c4ae8ed074380dafbc4c48cc3a3670ab35dc0cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Fuch=C3=9F?= Date: Mon, 2 Dec 2024 17:14:37 +0100 Subject: [PATCH] Cleanup --- .../connectors/generators/Extractor.java | 4 +- .../OriginalTextStateStrategy.java | 3 +- .../core/tests/eval/GoldStandardProject.java | 50 +++++++++---------- .../HoldBackRunResultsProducer.java | 3 +- .../tlrhelper/ModelElementSentenceLink.java | 2 - 5 files changed, 28 insertions(+), 34 deletions(-) diff --git a/stages-tlr/model-provider/src/main/java/edu/kit/kastel/mcse/ardoco/tlr/models/connectors/generators/Extractor.java b/stages-tlr/model-provider/src/main/java/edu/kit/kastel/mcse/ardoco/tlr/models/connectors/generators/Extractor.java index 701432f..0ec0af6 100644 --- a/stages-tlr/model-provider/src/main/java/edu/kit/kastel/mcse/ardoco/tlr/models/connectors/generators/Extractor.java +++ b/stages-tlr/model-provider/src/main/java/edu/kit/kastel/mcse/ardoco/tlr/models/connectors/generators/Extractor.java @@ -1,13 +1,11 @@ /* Licensed under MIT 2023-2024. */ package edu.kit.kastel.mcse.ardoco.tlr.models.connectors.generators; -import java.io.Serializable; - import edu.kit.kastel.mcse.ardoco.core.api.models.Metamodel; import edu.kit.kastel.mcse.ardoco.core.api.models.ModelType; import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.Model; -public abstract class Extractor implements Serializable { +public abstract class Extractor { protected String path; protected Extractor(String path) { diff --git a/stages-tlr/text-extraction/src/main/java/edu/kit/kastel/mcse/ardoco/tlr/textextraction/OriginalTextStateStrategy.java b/stages-tlr/text-extraction/src/main/java/edu/kit/kastel/mcse/ardoco/tlr/textextraction/OriginalTextStateStrategy.java index 5cc04f7..87123e5 100644 --- a/stages-tlr/text-extraction/src/main/java/edu/kit/kastel/mcse/ardoco/tlr/textextraction/OriginalTextStateStrategy.java +++ b/stages-tlr/text-extraction/src/main/java/edu/kit/kastel/mcse/ardoco/tlr/textextraction/OriginalTextStateStrategy.java @@ -1,7 +1,6 @@ /* Licensed under MIT 2022-2024. */ package edu.kit.kastel.mcse.ardoco.tlr.textextraction; -import java.io.Serializable; import java.util.Arrays; import java.util.stream.Collectors; @@ -20,7 +19,7 @@ import edu.kit.kastel.mcse.ardoco.core.data.Confidence; import edu.kit.kastel.mcse.ardoco.core.pipeline.agent.Claimant; -public class OriginalTextStateStrategy extends DefaultTextStateStrategy implements Serializable { +public class OriginalTextStateStrategy extends DefaultTextStateStrategy { protected OriginalTextStateStrategy() { } diff --git a/tests/integration-tests/tests-base/src/main/java/edu/kit/kastel/mcse/ardoco/core/tests/eval/GoldStandardProject.java b/tests/integration-tests/tests-base/src/main/java/edu/kit/kastel/mcse/ardoco/core/tests/eval/GoldStandardProject.java index bec95bd..47e889f 100644 --- a/tests/integration-tests/tests-base/src/main/java/edu/kit/kastel/mcse/ardoco/core/tests/eval/GoldStandardProject.java +++ b/tests/integration-tests/tests-base/src/main/java/edu/kit/kastel/mcse/ardoco/core/tests/eval/GoldStandardProject.java @@ -3,7 +3,6 @@ import java.io.File; import java.io.IOException; -import java.io.Serializable; import java.util.MissingResourceException; import java.util.Objects; import java.util.Optional; @@ -23,7 +22,7 @@ /** * Interface for all Project extensions */ -public interface GoldStandardProject extends Serializable { +public interface GoldStandardProject { /** * {@return the project the instance is based on} */ @@ -38,7 +37,7 @@ public interface GoldStandardProject extends Serializable { * {@return the version of the source files of this project} */ default long getSourceFilesVersion() { - getResourceNames().forEach(this::validateResourceChecksum); + this.getResourceNames().forEach(this::validateResourceChecksum); return Preferences.userNodeForPackage(getClass()).getLong("version", -1L); } @@ -53,8 +52,9 @@ private boolean validateResourceChecksum(String resourceName) { var cls = getClass(); var logger = LoggerFactory.getLogger(cls); try (var resource = cls.getResourceAsStream(resourceName)) { - if (resource == null) + if (resource == null) { throw new MissingResourceException("No such resource at path " + resourceName, File.class.getSimpleName(), resourceName); + } String md5 = DigestUtils.md5Hex(resource); if (!Objects.equals(Preferences.userNodeForPackage(cls).get(resourceName, null), md5)) { Preferences.userNodeForPackage(cls).put(resourceName, md5); @@ -74,7 +74,7 @@ private boolean validateResourceChecksum(String resourceName) { * {@return the project alias} */ default String getAlias() { - return getProjectOrThrow().getAlias(); + return this.getProjectOrThrow().getAlias(); } /** @@ -83,14 +83,14 @@ default String getAlias() { * @return the File that represents the model for this project */ default File getModelFile() { - return getProjectOrThrow().getModelFile(); + return this.getProjectOrThrow().getModelFile(); } /** * {@return the resource name that represents the model for this project} */ default String getModelResourceName() { - return getProjectOrThrow().getModelResourceName(); + return this.getProjectOrThrow().getModelResourceName(); } /** @@ -100,7 +100,7 @@ default String getModelResourceName() { * @return the File that represents the model for this project */ default File getModelFile(ArchitectureModelType modelType) { - return getProjectOrThrow().getModelFile(modelType); + return this.getProjectOrThrow().getModelFile(modelType); } /** @@ -109,7 +109,7 @@ default File getModelFile(ArchitectureModelType modelType) { * @param modelType the model type */ default String getModelResourceName(ArchitectureModelType modelType) { - return getProjectOrThrow().getModelResourceName(modelType); + return this.getProjectOrThrow().getModelResourceName(modelType); } /** @@ -118,14 +118,14 @@ default String getModelResourceName(ArchitectureModelType modelType) { * @return the File that represents the text for this project */ default File getTextFile() { - return getProjectOrThrow().getTextFile(); + return this.getProjectOrThrow().getTextFile(); } /** * {@return the resource name that represents the text for this project} */ default String getTextResourceName() { - return getProjectOrThrow().getTextResourceName(); + return this.getProjectOrThrow().getTextResourceName(); } /** @@ -134,7 +134,7 @@ default String getTextResourceName() { * @return the map of additional configuration options */ default SortedMap getAdditionalConfigurations() { - return getProjectOrThrow().getAdditionalConfigurations(); + return this.getProjectOrThrow().getAdditionalConfigurations(); } /** @@ -143,14 +143,14 @@ default SortedMap getAdditionalConfigurations() { * @return the file for additional configurations */ default File getAdditionalConfigurationsFile() { - return getProjectOrThrow().getAdditionalConfigurationsFile(); + return this.getProjectOrThrow().getAdditionalConfigurationsFile(); } /** * {@return the resource name that represents the additional configurations for this project} */ default String getAdditionalConfigurationsResourceName() { - return getProjectOrThrow().getAdditionalConfigurationsResourceName(); + return this.getProjectOrThrow().getAdditionalConfigurationsResourceName(); } /** @@ -159,14 +159,14 @@ default String getAdditionalConfigurationsResourceName() { * @return the File that represents the gold standard for this project */ default File getTlrGoldStandardFile() { - return getProjectOrThrow().getTlrGoldStandardFile(); + return this.getProjectOrThrow().getTlrGoldStandardFile(); } /** * {@return the resource name that represents the TLR {@link GoldStandard} for this project} */ default String getTlrGoldStandardResourceName() { - return getProjectOrThrow().getTlrGoldStandardResourceName(); + return this.getProjectOrThrow().getTlrGoldStandardResourceName(); } /** @@ -175,7 +175,7 @@ default String getTlrGoldStandardResourceName() { * @return a list with the entries of the goldstandard for TLR */ default ImmutableList getTlrGoldStandard() { - return getProjectOrThrow().getTlrGoldStandard(); + return this.getProjectOrThrow().getTlrGoldStandard(); } /** @@ -185,39 +185,39 @@ default ImmutableList getTlrGoldStandard() { * @return the {@link GoldStandard} for this project */ default GoldStandard getTlrGoldStandard(ArchitectureModel architectureModel) { - return getProjectOrThrow().getTlrGoldStandard(architectureModel); + return this.getProjectOrThrow().getTlrGoldStandard(architectureModel); } default MutableList getMissingTextForModelElementGoldStandard() { - return getProjectOrThrow().getMissingTextForModelElementGoldStandard(); + return this.getProjectOrThrow().getMissingTextForModelElementGoldStandard(); } /** * {@return the {@link GoldStandard} for this project} */ default File getMissingTextForModelElementGoldStandardFile() { - return getProjectOrThrow().getMissingTextForModelElementGoldStandardFile(); + return this.getProjectOrThrow().getMissingTextForModelElementGoldStandardFile(); } /** * {@return the resource name that represents the MME {@link GoldStandard} for this project} */ default String getMissingTextForModelElementGoldStandardResourceName() { - return getProjectOrThrow().getMissingTextForModelElementGoldStandardResourceName(); + return this.getProjectOrThrow().getMissingTextForModelElementGoldStandardResourceName(); } /** * {@return the expected results for Traceability Link Recovery} */ default ExpectedResults getExpectedTraceLinkResults() { - return getProjectOrThrow().getExpectedTraceLinkResults(); + return this.getProjectOrThrow().getExpectedTraceLinkResults(); } /** * {@return the expected results for Inconsistency Detection} */ default ExpectedResults getExpectedInconsistencyResults() { - return getProjectOrThrow().getExpectedInconsistencyResults(); + return this.getProjectOrThrow().getExpectedInconsistencyResults(); } /** @@ -226,7 +226,7 @@ default ExpectedResults getExpectedInconsistencyResults() { * @return the project this instance belongs to */ private Project getProjectOrThrow() { - return getFromName().orElseThrow(); + return this.getFromName().orElseThrow(); } /** @@ -236,7 +236,7 @@ private Project getProjectOrThrow() { */ private Optional getFromName() { for (Project project : Project.values()) { - if (project.name().equalsIgnoreCase(getProjectName())) { + if (project.name().equalsIgnoreCase(this.getProjectName())) { return Optional.of(project); } } diff --git a/tests/integration-tests/tests-inconsistency/src/test/java/edu/kit/kastel/mcse/ardoco/id/tests/integration/inconsistencyhelper/HoldBackRunResultsProducer.java b/tests/integration-tests/tests-inconsistency/src/test/java/edu/kit/kastel/mcse/ardoco/id/tests/integration/inconsistencyhelper/HoldBackRunResultsProducer.java index c75440d..6b0d089 100644 --- a/tests/integration-tests/tests-inconsistency/src/test/java/edu/kit/kastel/mcse/ardoco/id/tests/integration/inconsistencyhelper/HoldBackRunResultsProducer.java +++ b/tests/integration-tests/tests-inconsistency/src/test/java/edu/kit/kastel/mcse/ardoco/id/tests/integration/inconsistencyhelper/HoldBackRunResultsProducer.java @@ -2,7 +2,6 @@ package edu.kit.kastel.mcse.ardoco.id.tests.integration.inconsistencyhelper; import java.io.File; -import java.io.Serializable; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -28,7 +27,7 @@ * Produces the inconsistency detection runs. The first run uses all model elements for the baseline. For each subsequent run a single model element is removed * to simulate a missing model element. */ -public class HoldBackRunResultsProducer implements Serializable { +public class HoldBackRunResultsProducer { protected File inputText; protected File inputModel; protected SortedMap additionalConfigs; diff --git a/tests/integration-tests/tests-tlr/src/test/java/edu/kit/kastel/mcse/ardoco/tlr/tests/integration/tlrhelper/ModelElementSentenceLink.java b/tests/integration-tests/tests-tlr/src/test/java/edu/kit/kastel/mcse/ardoco/tlr/tests/integration/tlrhelper/ModelElementSentenceLink.java index 03eca63..a7259ec 100644 --- a/tests/integration-tests/tests-tlr/src/test/java/edu/kit/kastel/mcse/ardoco/tlr/tests/integration/tlrhelper/ModelElementSentenceLink.java +++ b/tests/integration-tests/tests-tlr/src/test/java/edu/kit/kastel/mcse/ardoco/tlr/tests/integration/tlrhelper/ModelElementSentenceLink.java @@ -6,7 +6,6 @@ import edu.kit.kastel.mcse.ardoco.core.api.entity.ArchitectureEntity; import edu.kit.kastel.mcse.ardoco.core.api.text.SentenceEntity; import edu.kit.kastel.mcse.ardoco.core.api.tracelink.SadSamTraceLink; -import edu.kit.kastel.mcse.ardoco.core.common.Internal; /** * Represents a simple trace link by the id of the model and number of the sentence involved. @@ -17,7 +16,6 @@ public ModelElementSentenceLink(SadSamTraceLink traceLink) { this(traceLink.getArchitectureEntityId(), traceLink.getSentenceNumber()); } - @Internal public ModelElementSentenceLink(SentenceEntity sentence, ArchitectureEntity architectureEntity) { this(architectureEntity.getId(), sentence.getSentence().getSentenceNumber()); }