diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/codetraceability/CodeTraceabilityState.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/codetraceability/CodeTraceabilityState.java index 800dc9ecf..3064b0b5a 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/codetraceability/CodeTraceabilityState.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/codetraceability/CodeTraceabilityState.java @@ -5,8 +5,8 @@ import org.eclipse.collections.api.set.ImmutableSet; -import edu.kit.kastel.mcse.ardoco.core.api.models.ArchitectureEntity; import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.CodeCompilationUnit; +import edu.kit.kastel.mcse.ardoco.core.api.models.entity.ArchitectureEntity; import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.SadCodeTraceLink; import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.SamCodeTraceLink; import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.TraceLink; @@ -33,7 +33,7 @@ public interface CodeTraceabilityState extends PipelineStepData { * @param traceLinks the trace links to add * @return whether the operation was successful */ - boolean addSamCodeTraceLinks(Collection> traceLinks); + boolean addSamCodeTraceLinks(Collection> traceLinks); /** * Return a set of stored {@link SamCodeTraceLink SamCodeTraceLinks}. @@ -56,7 +56,7 @@ public interface CodeTraceabilityState extends PipelineStepData { * @param traceLinks the trace links to add * @return whether the operation was successful */ - boolean addSadCodeTraceLinks(Collection> traceLinks); + boolean addSadCodeTraceLinks(Collection> traceLinks); /** * Return a set of stored {@link TransitiveTraceLink TransitiveTraceLinks}. diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/connectiongenerator/ConnectionState.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/connectiongenerator/ConnectionState.java index 23929ec10..8214b53f6 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/connectiongenerator/ConnectionState.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/connectiongenerator/ConnectionState.java @@ -6,9 +6,8 @@ import org.eclipse.collections.api.set.ImmutableSet; import org.eclipse.collections.api.set.MutableSet; -import edu.kit.kastel.mcse.ardoco.core.api.models.ArchitectureEntity; -import edu.kit.kastel.mcse.ardoco.core.api.models.ModelInstance; -import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.InstanceLink; +import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy.ModelInstance; +import edu.kit.kastel.mcse.ardoco.core.api.models.entity.ArchitectureEntity; import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.SadSamTraceLink; import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.TraceLink; import edu.kit.kastel.mcse.ardoco.core.api.recommendationgenerator.RecommendedInstance; diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/InstanceLink.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/connectiongenerator/InstanceLink.java similarity index 76% rename from framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/InstanceLink.java rename to framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/connectiongenerator/InstanceLink.java index 6b457e919..5ae5bc8e6 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/InstanceLink.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/connectiongenerator/InstanceLink.java @@ -1,5 +1,5 @@ /* Licensed under MIT 2021-2024. */ -package edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks; +package edu.kit.kastel.mcse.ardoco.core.api.connectiongenerator; import java.util.Arrays; import java.util.LinkedHashSet; @@ -9,11 +9,13 @@ import org.eclipse.collections.api.factory.Lists; import org.eclipse.collections.api.list.MutableList; -import edu.kit.kastel.mcse.ardoco.core.api.models.ModelInstance; +import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy.ModelInstance; +import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.EndpointTuple; import edu.kit.kastel.mcse.ardoco.core.api.recommendationgenerator.RecommendedInstance; import edu.kit.kastel.mcse.ardoco.core.api.textextraction.NounMapping; import edu.kit.kastel.mcse.ardoco.core.architecture.Deterministic; import edu.kit.kastel.mcse.ardoco.core.common.AggregationFunctions; +import edu.kit.kastel.mcse.ardoco.core.common.Internal; import edu.kit.kastel.mcse.ardoco.core.data.Confidence; import edu.kit.kastel.mcse.ardoco.core.pipeline.agent.Claimant; @@ -21,8 +23,11 @@ * An InstanceLink defines a link between an {@link RecommendedInstance} and an {@link ModelInstance}. */ @Deterministic +@Internal public class InstanceLink extends EndpointTuple { + private static final long serialVersionUID = -8630933950725516269L; + private final RecommendedInstance textualInstance; private final ModelInstance modelInstance; private final Confidence confidence; @@ -55,7 +60,7 @@ public InstanceLink(RecommendedInstance textualInstance, ModelInstance modelInst /** * Add confidence to this link. - * + * * @param claimant the claimant that wants to change the confidence * @param confidence the confidence value to add */ @@ -69,7 +74,7 @@ public final void addConfidence(Claimant claimant, double confidence) { * @return the probability of this link */ public final double getConfidence() { - return confidence.getConfidence(); + return this.confidence.getConfidence(); } /** @@ -78,7 +83,7 @@ public final double getConfidence() { * @return the textual instance */ public final RecommendedInstance getTextualInstance() { - return textualInstance; + return this.textualInstance; } /** @@ -87,12 +92,12 @@ public final RecommendedInstance getTextualInstance() { * @return the extracted instance */ public final ModelInstance getModelInstance() { - return modelInstance; + return this.modelInstance; } @Override public int hashCode() { - return Objects.hash(modelInstance, textualInstance); + return Objects.hash(this.modelInstance, this.textualInstance); } @Override @@ -103,7 +108,7 @@ public boolean equals(Object obj) { if (!(obj instanceof InstanceLink other)) { return false; } - return Objects.equals(getModelInstance(), other.getModelInstance()) && Objects.equals(getTextualInstance(), other.getTextualInstance()); + return Objects.equals(this.getModelInstance(), other.getModelInstance()) && Objects.equals(this.getTextualInstance(), other.getTextualInstance()); } @Override @@ -113,17 +118,17 @@ public String toString() { Set types = new LinkedHashSet<>(); MutableList typePositions = Lists.mutable.empty(); - for (NounMapping nameMapping : textualInstance.getNameMappings()) { + for (NounMapping nameMapping : this.textualInstance.getNameMappings()) { names.addAll(nameMapping.getSurfaceForms().castToCollection()); namePositions.addAll(nameMapping.getMappingSentenceNo().castToCollection()); } - for (NounMapping typeMapping : textualInstance.getTypeMappings()) { + for (NounMapping typeMapping : this.textualInstance.getTypeMappings()) { types.addAll(typeMapping.getSurfaceForms().castToCollection()); typePositions.addAll(typeMapping.getMappingSentenceNo().castToCollection()); } - return "InstanceMapping [ uid=" + modelInstance.getUid() + ", name=" + modelInstance.getFullName() + // - ", as=" + String.join(", ", modelInstance.getFullType()) + ", probability=" + getConfidence() + ", FOUND: " + // - textualInstance.getName() + " : " + textualInstance.getType() + ", occurrences= " + // + return "InstanceMapping [ uid=" + this.modelInstance.getUid() + ", name=" + this.modelInstance.getFullName() + // + ", as=" + String.join(", ", this.modelInstance.getFullType()) + ", probability=" + this.getConfidence() + ", FOUND: " + // + this.textualInstance.getName() + " : " + this.textualInstance.getType() + ", occurrences= " + // "NameVariants: " + names.size() + ": " + names + " sentences{" + Arrays.toString(namePositions.toArray()) + "}" + // ", TypeVariants: " + types.size() + ": " + types + "sentences{" + Arrays.toString(typePositions.toArray()) + "}" + "]"; } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ArchitectureModelType.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ArchitectureModelType.java index 89e1040ee..9bb5cb55c 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ArchitectureModelType.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ArchitectureModelType.java @@ -19,7 +19,7 @@ public enum ArchitectureModelType implements ModelType { RAW; @Override - public String getModelId() { - return this.name(); + public Metamodel getMetamodel() { + return Metamodel.ARCHITECTURE; } } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/CodeModelType.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/CodeModelType.java index 2a4eee106..3521e2fc5 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/CodeModelType.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/CodeModelType.java @@ -5,7 +5,7 @@ public enum CodeModelType implements ModelType { CODE_MODEL; @Override - public String getModelId() { - return "CodeModel"; + public Metamodel getMetamodel() { + return Metamodel.CODE; } } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/Entity.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/Entity.java deleted file mode 100644 index f4de857e5..000000000 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/Entity.java +++ /dev/null @@ -1,65 +0,0 @@ -/* Licensed under MIT 2023-2024. */ -package edu.kit.kastel.mcse.ardoco.core.api.models; - -import java.io.Serializable; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * An entity with a name. Is a model element. - */ -public abstract sealed class Entity extends ModelElement implements Serializable permits ArchitectureEntity, TextEntity, CodeEntity { - - @JsonProperty - private String name; - - protected Entity() { - // Jackson - } - - /** - * Creates a new entity with the specified name. - * - * @param name the name of the entity to be created - */ - protected Entity(String name) { - this.name = name; - } - - protected Entity(String name, String id) { - super(id); - this.name = name; - } - - /** - * Returns the entity's name. - * - * @return the entity's name - */ - public String getName() { - return name; - } - - @Override - public String toString() { - return name; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (!(o instanceof Entity entity)) - return false; - if (!super.equals(o)) - return false; - return name.equals(entity.name) && getId().equals(entity.getId()); - } - - @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + name.hashCode(); - return 31 * result + getId().hashCode(); - } -} diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ModelElement.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ModelElement.java deleted file mode 100644 index dc1306499..000000000 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ModelElement.java +++ /dev/null @@ -1,50 +0,0 @@ -/* Licensed under MIT 2023-2024. */ -package edu.kit.kastel.mcse.ardoco.core.api.models; - -import java.io.Serializable; -import java.util.Objects; - -import edu.kit.kastel.mcse.ardoco.core.common.IdentifierProvider; - -/** - * A model element. Has an identifier. Two model elements are equal if and only if they have the same identifier. - */ -public abstract class ModelElement implements Comparable, Serializable { - - private final String id; - - protected ModelElement() { - this.id = IdentifierProvider.createId(); - } - - protected ModelElement(String id) { - this.id = id; - } - - public String getId() { - return id; - } - - @Override - public int hashCode() { - return Objects.hash(id); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof ModelElement other)) { - return false; - } - return Objects.equals(id, other.id); - } - - @Override - public int compareTo(ModelElement o) { - if (this.equals(o)) - return 0; - return this.id.compareTo(o.id); - } -} diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ModelStates.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ModelStates.java index e888e9b24..a2e5cc90f 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ModelStates.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ModelStates.java @@ -9,13 +9,17 @@ import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.ArchitectureModel; import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.CodeModel; import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.Model; +import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy.LegacyModelExtractionState; +import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy.LegacyModelExtractionStateByArCoTL; import edu.kit.kastel.mcse.ardoco.core.data.PipelineStepData; public class ModelStates implements PipelineStepData { + private static final long serialVersionUID = -603436842247064371L; + public static final String ID = "ModelStatesData"; - private SortedMap models = new TreeMap<>(); - private SortedMap legacyModels = new TreeMap<>(); + private SortedMap models = new TreeMap<>(); + private SortedMap legacyModels = new TreeMap<>(); /** * Constructor to create a {@link ModelStates} object that holds all {@link LegacyModelExtractionState}s @@ -29,23 +33,25 @@ public ModelStates() { * * @param id the id * @return the corresponding {@link LegacyModelExtractionState} - * @deprecated use {@link #getModel(String)} instead + * @deprecated use {@link #getModel(Metamodel)} instead */ @Deprecated - public LegacyModelExtractionState getModelExtractionState(String id) { - if (legacyModels.containsKey(id)) - return legacyModels.get(id); + public LegacyModelExtractionState getModelExtractionState(Metamodel id) { + if (this.legacyModels.containsKey(id)) { + return this.legacyModels.get(id); + } - var model = models.get(id); - if (model == null) + var model = this.models.get(id); + if (model == null) { return null; + } var legacyModel = switch (model) { case ArchitectureModel am -> new LegacyModelExtractionStateByArCoTL(am); case CodeModel cm -> new LegacyModelExtractionStateByArCoTL(cm); }; - legacyModels.put(id, legacyModel); + this.legacyModels.put(id, legacyModel); return legacyModel; } @@ -54,8 +60,8 @@ public LegacyModelExtractionState getModelExtractionState(String id) { * * @return the IDs of all contained {@link Model Models} */ - public SortedSet modelIds() { - return new TreeSet<>(models.keySet()); + public SortedSet modelIds() { + return new TreeSet<>(this.models.keySet()); } /** @@ -64,8 +70,8 @@ public SortedSet modelIds() { * @param id the id * @param model the {@link Model} */ - public void addModel(String id, Model model) { - models.put(id, model); + public void addModel(Metamodel id, Model model) { + this.models.put(id, model); } /** @@ -74,8 +80,8 @@ public void addModel(String id, Model model) { * @param id the id * @return the corresponding {@link Model} */ - public Model getModel(String id) { - return models.get(id); + public Model getModel(Metamodel id) { + return this.models.get(id); } } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ModelType.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ModelType.java index 22e715a57..e36853e2b 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ModelType.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ModelType.java @@ -2,5 +2,5 @@ package edu.kit.kastel.mcse.ardoco.core.api.models; public interface ModelType { - String getModelId(); + Metamodel getMetamodel(); } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/CodeModel.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/CodeModel.java index 068d6e8b0..2324b0501 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/CodeModel.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/CodeModel.java @@ -11,11 +11,11 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import edu.kit.kastel.mcse.ardoco.core.api.models.Entity; import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.CodeCompilationUnit; import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.CodeItem; import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.CodeItemRepository; import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.CodePackage; +import edu.kit.kastel.mcse.ardoco.core.api.models.entity.Entity; /** * A code model that is a CMTL instance. diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/Model.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/Model.java index 5959c4e8a..52ec6a926 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/Model.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/Model.java @@ -3,10 +3,16 @@ import java.util.List; -import edu.kit.kastel.mcse.ardoco.core.api.models.Entity; -import edu.kit.kastel.mcse.ardoco.core.api.models.ModelElement; +import edu.kit.kastel.mcse.ardoco.core.api.models.entity.Entity; +import edu.kit.kastel.mcse.ardoco.core.common.IdentifierProvider; -public abstract sealed class Model extends ModelElement permits ArchitectureModel, CodeModel { +public abstract sealed class Model permits ArchitectureModel, CodeModel { + + private final String id = IdentifierProvider.createId(); + + public String getId() { + return this.id; + } /** * Returns the content of this model. diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/ArchitectureComponent.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/ArchitectureComponent.java index 3f3be5e4e..b2f7dc7e7 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/ArchitectureComponent.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/ArchitectureComponent.java @@ -12,6 +12,8 @@ */ public final class ArchitectureComponent extends ArchitectureItem { + private static final long serialVersionUID = -7349058662425121364L; + private final SortedSet subcomponents; private final SortedSet providedInterfaces; @@ -33,7 +35,7 @@ public ArchitectureComponent(String name, String id, SortedSet getSubcomponents() { - return subcomponents; + return this.subcomponents; } /** @@ -43,7 +45,7 @@ public SortedSet getSubcomponents() { * @return the provided interfaces of this component */ public SortedSet getProvidedInterfaces() { - return providedInterfaces; + return this.providedInterfaces; } /** @@ -53,7 +55,7 @@ public SortedSet getProvidedInterfaces() { * @return the required interfaces of this component */ public SortedSet getRequiredInterfaces() { - return requiredInterfaces; + return this.requiredInterfaces; } /** @@ -62,36 +64,30 @@ public SortedSet getRequiredInterfaces() { * @return the type of this component */ public String getType() { - return type; + return this.type; } @Override public String toString() { - return "Component: " + getName(); + return "Component: " + this.getName(); } @Override public boolean equals(Object o) { - if (this == o) + if (this == o) { return true; - if (!(o instanceof ArchitectureComponent that)) - return false; - if (!super.equals(o)) - return false; - - if (!subcomponents.equals(that.subcomponents)) - return false; - if (!providedInterfaces.equals(that.providedInterfaces)) + } + if (!(o instanceof ArchitectureComponent that) || !super.equals(o) || !this.subcomponents.equals(that.subcomponents) || !this.providedInterfaces.equals(that.providedInterfaces)) { return false; - return requiredInterfaces.equals(that.requiredInterfaces); + } + return this.requiredInterfaces.equals(that.requiredInterfaces); } @Override public int hashCode() { int result = super.hashCode(); - result = 31 * result + subcomponents.hashCode(); - result = 31 * result + providedInterfaces.hashCode(); - result = 31 * result + requiredInterfaces.hashCode(); - return result; + result = 31 * result + this.subcomponents.hashCode(); + result = 31 * result + this.providedInterfaces.hashCode(); + return 31 * result + this.requiredInterfaces.hashCode(); } } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/ArchitectureInterface.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/ArchitectureInterface.java index be17504d4..48884aef8 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/ArchitectureInterface.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/ArchitectureInterface.java @@ -6,6 +6,8 @@ public final class ArchitectureInterface extends ArchitectureItem { + private static final long serialVersionUID = 2232013345166120690L; + private final SortedSet signatures; public ArchitectureInterface(String name, String id, SortedSet signatures) { @@ -14,27 +16,27 @@ public ArchitectureInterface(String name, String id, SortedSet getSignatures() { - return signatures; + return this.signatures; } @Override public String toString() { - return "Interface: " + getName(); + return "Interface: " + this.getName(); } @Override public boolean equals(Object o) { - if (this == o) + if (this == o) { return true; - if (!(o instanceof ArchitectureInterface that)) - return false; - if (!super.equals(o)) + } + if (!(o instanceof ArchitectureInterface that) || !super.equals(o)) { return false; - return Objects.equals(signatures, that.signatures); + } + return Objects.equals(this.signatures, that.signatures); } @Override public int hashCode() { - return Objects.hash(super.hashCode(), signatures); + return Objects.hash(super.hashCode(), this.signatures); } } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/ArchitectureItem.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/ArchitectureItem.java index 681bff859..206bd83f8 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/ArchitectureItem.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/ArchitectureItem.java @@ -1,7 +1,7 @@ /* Licensed under MIT 2023-2024. */ package edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture; -import edu.kit.kastel.mcse.ardoco.core.api.models.ArchitectureEntity; +import edu.kit.kastel.mcse.ardoco.core.api.models.entity.ArchitectureEntity; /** * An architecture item of an architecture model. A possible candidate for the @@ -10,6 +10,8 @@ */ public abstract sealed class ArchitectureItem extends ArchitectureEntity permits ArchitectureComponent, ArchitectureInterface, ArchitectureMethod { + private static final long serialVersionUID = -216185356134452192L; + /** * Creates a new architecture item with the specified name. * diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/ArchitectureMethod.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/ArchitectureMethod.java index 52ef3ae23..e178b932a 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/ArchitectureMethod.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/ArchitectureMethod.java @@ -3,6 +3,8 @@ public final class ArchitectureMethod extends ArchitectureItem { + private static final long serialVersionUID = 6560555992331464264L; + public ArchitectureMethod(String name) { super(name); } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/LegacyModelExtractionState.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/legacy/LegacyModelExtractionState.java similarity index 84% rename from framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/LegacyModelExtractionState.java rename to framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/legacy/LegacyModelExtractionState.java index eae127f2b..96ab19a0a 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/LegacyModelExtractionState.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/legacy/LegacyModelExtractionState.java @@ -1,17 +1,19 @@ /* Licensed under MIT 2021-2024. */ -package edu.kit.kastel.mcse.ardoco.core.api.models; +package edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy; import java.io.Serializable; import org.eclipse.collections.api.list.ImmutableList; import org.eclipse.collections.api.set.sorted.ImmutableSortedSet; +import edu.kit.kastel.mcse.ardoco.core.api.models.Metamodel; +import edu.kit.kastel.mcse.ardoco.core.api.models.ModelStates; import edu.kit.kastel.mcse.ardoco.core.configuration.IConfigurable; /** * The Interface IModelState defines the information directly extracted from the models. - * - * @deprecated use {@link ModelStates#getModel(String)} + * + * @deprecated use {@link ModelStates#getModel(Metamodel)} */ @Deprecated(since = "0.32.0") public interface LegacyModelExtractionState extends IConfigurable, Serializable { diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/LegacyModelExtractionStateByArCoTL.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/legacy/LegacyModelExtractionStateByArCoTL.java similarity index 70% rename from framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/LegacyModelExtractionStateByArCoTL.java rename to framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/legacy/LegacyModelExtractionStateByArCoTL.java index 702bc1860..25a73fb29 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/LegacyModelExtractionStateByArCoTL.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/legacy/LegacyModelExtractionStateByArCoTL.java @@ -1,5 +1,5 @@ /* Licensed under MIT 2023. */ -package edu.kit.kastel.mcse.ardoco.core.api.models; +package edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy; import java.util.ArrayList; import java.util.Collection; @@ -16,15 +16,23 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import edu.kit.kastel.mcse.ardoco.core.api.models.Metamodel; import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.ArchitectureModel; import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.CodeModel; import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.ArchitectureComponent; import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.ArchitectureInterface; import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.ArchitectureItem; import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.ArchitectureMethod; -import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.*; +import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.ClassUnit; +import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.CodeCompilationUnit; +import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.CodeModule; +import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.CodePackage; +import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.InterfaceUnit; +import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.ProgrammingLanguages; public class LegacyModelExtractionStateByArCoTL implements LegacyModelExtractionState { + private static final long serialVersionUID = -9079063953852495629L; + private static final Logger logger = LoggerFactory.getLogger(LegacyModelExtractionStateByArCoTL.class); private final String modelId; @@ -38,21 +46,21 @@ public class LegacyModelExtractionStateByArCoTL implements LegacyModelExtraction public LegacyModelExtractionStateByArCoTL(ArchitectureModel architectureModel) { this.modelId = architectureModel.getId(); - this.instances = initArchitectureInstances(architectureModel); + this.instances = LegacyModelExtractionStateByArCoTL.initArchitectureInstances(architectureModel); this.metamodel = Metamodel.ARCHITECTURE; - instanceTypes = SortedSets.mutable.empty(); - names = SortedSets.mutable.empty(); - collectTypesAndNames(); + this.instanceTypes = SortedSets.mutable.empty(); + this.names = SortedSets.mutable.empty(); + this.collectTypesAndNames(); } public LegacyModelExtractionStateByArCoTL(CodeModel codeModel) { this.modelId = codeModel.getId(); - this.instances = initCodeInstances(codeModel); + this.instances = LegacyModelExtractionStateByArCoTL.initCodeInstances(codeModel); this.metamodel = Metamodel.CODE; - instanceTypes = SortedSets.mutable.empty(); - names = SortedSets.mutable.empty(); - collectTypesAndNames(); + this.instanceTypes = SortedSets.mutable.empty(); + this.names = SortedSets.mutable.empty(); + this.collectTypesAndNames(); } private static ImmutableList initArchitectureInstances(ArchitectureModel architectureModel) { @@ -60,8 +68,8 @@ private static ImmutableList initArchitectureInstances(Architectu for (ArchitectureItem architectureItem : architectureModel.getEndpoints()) { switch (architectureItem) { case ArchitectureComponent component -> instances.add(new ModelInstanceImpl(component.getName(), component.getType(), component.getId())); - case ArchitectureInterface ignored -> logger.debug("Skipping .. ArchitectureInterface not supported yet"); - case ArchitectureMethod ignored -> logger.debug("Skipping .. ArchitectureMethod not supported yet"); + case ArchitectureInterface ignored -> LegacyModelExtractionStateByArCoTL.logger.debug("Skipping .. ArchitectureInterface not supported yet"); + case ArchitectureMethod ignored -> LegacyModelExtractionStateByArCoTL.logger.debug("Skipping .. ArchitectureMethod not supported yet"); } } return instances.toImmutable(); @@ -69,8 +77,8 @@ private static ImmutableList initArchitectureInstances(Architectu private static ImmutableList initCodeInstances(CodeModel codeModel) { List instances = new ArrayList<>(); - fillPackages(codeModel.getAllPackages(), instances); - fillCompilationUnits(codeModel.getEndpoints(), instances); + LegacyModelExtractionStateByArCoTL.fillPackages(codeModel.getAllPackages(), instances); + LegacyModelExtractionStateByArCoTL.fillCompilationUnits(codeModel.getEndpoints(), instances); return Lists.immutable.withAll(instances); } @@ -90,7 +98,7 @@ private static void fillPackages(Collection packages, Lis private static void fillCompilationUnits(Collection units, List instances) { for (var unit : units) { - String type = findType(unit); + String type = LegacyModelExtractionStateByArCoTL.findType(unit); instances.add(new ModelInstanceImpl(unit.getName(), type, unit.getPath())); } @@ -112,16 +120,16 @@ private static String findType(CodeCompilationUnit unit) { // Default to Class return "Class"; } - if (unit.getLanguage() == ProgrammingLanguage.SHELL) { + if (unit.getLanguage() == ProgrammingLanguages.SHELL) { return "ShellScript"; } throw new IllegalStateException("Unknown type of CodeCompilationUnit"); } private void collectTypesAndNames() { - for (ModelInstance i : instances) { - instanceTypes.addAll(i.getTypeParts().castToCollection()); - names.addAll(i.getNameParts().castToCollection()); + for (ModelInstance i : this.instances) { + this.instanceTypes.addAll(i.getTypeParts().castToCollection()); + this.names.addAll(i.getNameParts().castToCollection()); } } @@ -137,28 +145,28 @@ public Metamodel getMetamodel() { @Override public ImmutableList getInstancesOfType(String type) { - return instances.select(i -> i.getTypeParts().contains(type)); + return this.instances.select(i -> i.getTypeParts().contains(type)); } @Override public ImmutableSortedSet getInstanceTypes() { - return instanceTypes.toImmutable(); + return this.instanceTypes.toImmutable(); } @Override public ImmutableSortedSet getNames() { - return names.toImmutable(); + return this.names.toImmutable(); } @Override public ImmutableList getInstances() { - return instances; + return this.instances; } @Override public String toString() { var output = new StringBuilder("Instances:\n"); - for (ModelInstance i : instances) { + for (ModelInstance i : this.instances) { output.append(i.toString()).append("\n"); } return output.toString(); @@ -171,6 +179,6 @@ public void applyConfiguration(SortedMap additionalConfiguration @Override public SortedMap getLastAppliedConfiguration() { - return lastConfig; + return this.lastConfig; } } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ModelInstance.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/legacy/ModelInstance.java similarity index 83% rename from framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ModelInstance.java rename to framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/legacy/ModelInstance.java index 4a4216577..486720922 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ModelInstance.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/legacy/ModelInstance.java @@ -1,13 +1,18 @@ /* Licensed under MIT 2021-2024. */ -package edu.kit.kastel.mcse.ardoco.core.api.models; +package edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy; import org.eclipse.collections.api.list.ImmutableList; +import edu.kit.kastel.mcse.ardoco.core.api.models.entity.ArchitectureEntity; + /** * The Interface IModelInstance defines instances from models. */ +@Deprecated public abstract sealed class ModelInstance extends ArchitectureEntity permits ModelInstanceImpl { + private static final long serialVersionUID = 2351521910499184817L; + protected ModelInstance(String name, String id) { super(name, id); } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ModelInstanceImpl.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/legacy/ModelInstanceImpl.java similarity index 71% rename from framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ModelInstanceImpl.java rename to framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/legacy/ModelInstanceImpl.java index f9cc2b16f..4ce43719c 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ModelInstanceImpl.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/architecture/legacy/ModelInstanceImpl.java @@ -1,5 +1,5 @@ /* Licensed under MIT 2021-2023. */ -package edu.kit.kastel.mcse.ardoco.core.api.models; +package edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy; import java.util.Objects; @@ -13,8 +13,11 @@ * This class represents an instance extracted from a model. The name of an instance (as well as the type) are splitted at spaces and can be seen as multiple * names. Therefore, the longestName (and type) is the original name (type) of the instance. */ +@Deprecated public final class ModelInstanceImpl extends ModelInstance { + private static final long serialVersionUID = 9185325416212743266L; + private final String fullName; private final String fullType; private final MutableList names; @@ -32,19 +35,19 @@ public ModelInstanceImpl(String name, String type, String uid) { super(name, uid); String splitName = CommonUtilities.splitCases(name); - names = Lists.mutable.with(splitName.split(" ")); - if (names.size() > 1) { - names.add(name); + this.names = Lists.mutable.with(splitName.split(" ")); + if (this.names.size() > 1) { + this.names.add(name); } String splitType = CommonUtilities.splitCases(type); - types = Lists.mutable.with(splitType.split(" ")); - if (types.size() > 1) { - types.add(type); + this.types = Lists.mutable.with(splitType.split(" ")); + if (this.types.size() > 1) { + this.types.add(type); } this.uid = uid; - fullName = name; - fullType = type; + this.fullName = name; + this.fullType = type; } /** @@ -54,7 +57,7 @@ public ModelInstanceImpl(String name, String type, String uid) { */ @Override public String getFullName() { - return fullName; + return this.fullName; } /** @@ -64,7 +67,7 @@ public String getFullName() { */ @Override public String getFullType() { - return fullType; + return this.fullType; } /** @@ -74,7 +77,7 @@ public String getFullType() { */ @Override public ImmutableList getNameParts() { - return names.toImmutable(); + return this.names.toImmutable(); } /** @@ -84,7 +87,7 @@ public ImmutableList getNameParts() { */ @Override public ImmutableList getTypeParts() { - return types.toImmutable(); + return this.types.toImmutable(); } /** @@ -94,17 +97,17 @@ public ImmutableList getTypeParts() { */ @Override public String getUid() { - return uid; + return this.uid; } @Override public String toString() { - return "Instance [names=" + String.join(", ", names) + ", type=" + String.join(", ", types) + "]"; + return "Instance [names=" + String.join(", ", this.names) + ", type=" + String.join(", ", this.types) + "]"; } @Override public int hashCode() { - return Objects.hash(fullName, fullType, uid); + return Objects.hash(this.fullName, this.fullType, this.uid); } @Override @@ -115,7 +118,7 @@ public boolean equals(Object obj) { if (!(obj instanceof ModelInstanceImpl other)) { return false; } - return Objects.equals(fullName, other.fullName) && Objects.equals(fullType, other.fullType) && Objects.equals(uid, other.uid); + return Objects.equals(this.fullName, other.fullName) && Objects.equals(this.fullType, other.fullType) && Objects.equals(this.uid, other.uid); } } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/ClassUnit.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/ClassUnit.java index 1091ae6ba..126ea60ba 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/ClassUnit.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/ClassUnit.java @@ -12,13 +12,15 @@ @JsonTypeName("ClassUnit") public final class ClassUnit extends Datatype { + private static final long serialVersionUID = 354013115794534271L; + @JsonProperty private final List content; @SuppressWarnings("unused") private ClassUnit() { // Jackson - content = new ArrayList<>(); + this.content = new ArrayList<>(); } public ClassUnit(CodeItemRepository codeItemRepository, String name, SortedSet content) { @@ -31,37 +33,36 @@ public ClassUnit(CodeItemRepository codeItemRepository, String name, SortedSet getContentIds() { - return content; + return this.content; } @Override public List getContent() { - return codeItemRepository.getCodeItemsFromIds(content); + return this.codeItemRepository.getCodeItemsFromIds(this.content); } @Override public List getAllDataTypes() { List result = new ArrayList<>(); result.add(this); - getContent().forEach(c -> result.addAll(c.getAllDataTypes())); + this.getContent().forEach(c -> result.addAll(c.getAllDataTypes())); return result; } @Override public boolean equals(Object o) { - if (this == o) + if (this == o) { return true; - if (!(o instanceof ClassUnit classUnit)) - return false; - if (!super.equals(o)) + } + if (!(o instanceof ClassUnit classUnit) || !super.equals(o)) { return false; - return content.equals(classUnit.content); + } + return this.content.equals(classUnit.content); } @Override public int hashCode() { int result = super.hashCode(); - result = 31 * result + content.hashCode(); - return result; + return 31 * result + this.content.hashCode(); } } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodeAssembly.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodeAssembly.java index 82fe3bb6b..aba02d335 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodeAssembly.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodeAssembly.java @@ -8,6 +8,8 @@ @JsonTypeName("CodeAssembly") public final class CodeAssembly extends CodeModule { + private static final long serialVersionUID = 3082912967900986071L; + @SuppressWarnings("unused") private CodeAssembly() { // Jackson diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodeCompilationUnit.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodeCompilationUnit.java index 2b0da3d08..ec5440cb2 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodeCompilationUnit.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodeCompilationUnit.java @@ -17,12 +17,14 @@ @JsonTypeName("CodeCompilationUnit") public final class CodeCompilationUnit extends CodeModule { + private static final long serialVersionUID = 6749513760670983294L; + @JsonProperty private List pathElements; @JsonProperty private String extension; @JsonProperty - private ProgrammingLanguage language; + private String language; @SuppressWarnings("unused") private CodeCompilationUnit() { @@ -30,21 +32,21 @@ private CodeCompilationUnit() { } public CodeCompilationUnit(CodeItemRepository codeItemRepository, String name, SortedSet content, List pathElements, - String extension, ProgrammingLanguage language) { + String extension, String language) { super(codeItemRepository, name, content); this.pathElements = new ArrayList<>(pathElements); this.extension = extension; this.language = language; } - public ProgrammingLanguage getLanguage() { - return language; + public String getLanguage() { + return this.language; } @Override public List getAllDataTypes() { List result = new ArrayList<>(); - getContent().forEach(c -> result.addAll(c.getAllDataTypes())); + this.getContent().forEach(c -> result.addAll(c.getAllDataTypes())); return result; } @@ -68,49 +70,44 @@ public List getParentPackageNames() { } public List getPathElements() { - return new ArrayList<>(pathElements); + return new ArrayList<>(this.pathElements); } public String getPath() { StringBuilder pathBuilder = new StringBuilder(); - for (String pathElement : pathElements) { + for (String pathElement : this.pathElements) { pathBuilder.append(pathElement).append("/"); } String ending = ""; - if (!extension.isEmpty()) { - ending = "." + extension; + if (!this.extension.isEmpty()) { + ending = "." + this.extension; } - pathBuilder.append(getName()).append(ending); + pathBuilder.append(this.getName()).append(ending); return pathBuilder.toString(); } @Override public String toString() { - return getPath(); + return this.getPath(); } @Override public boolean equals(Object o) { - if (this == o) + if (this == o) { return true; - if (!(o instanceof CodeCompilationUnit that)) - return false; - if (!super.equals(o)) - return false; - - if (!Objects.equals(pathElements, that.pathElements)) - return false; - if (!Objects.equals(extension, that.extension)) + } + if (!(o instanceof CodeCompilationUnit that) || !super.equals(o) || !Objects.equals(this.pathElements, that.pathElements) || !Objects.equals( + this.extension, that.extension)) { return false; - return language == that.language; + } + return this.language == that.language; } @Override public int hashCode() { int result = super.hashCode(); - result = 31 * result + (pathElements != null ? pathElements.hashCode() : 0); - result = 31 * result + (extension != null ? extension.hashCode() : 0); - result = 31 * result + (language != null ? language.hashCode() : 0); - return result; + result = 31 * result + (this.pathElements != null ? this.pathElements.hashCode() : 0); + result = 31 * result + (this.extension != null ? this.extension.hashCode() : 0); + return 31 * result + (this.language != null ? this.language.hashCode() : 0); } } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodeItem.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodeItem.java index 5dc7a23b9..e796bf91d 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodeItem.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodeItem.java @@ -11,7 +11,7 @@ import com.fasterxml.jackson.annotation.JsonSubTypes; import com.fasterxml.jackson.annotation.JsonTypeInfo; -import edu.kit.kastel.mcse.ardoco.core.api.models.CodeEntity; +import edu.kit.kastel.mcse.ardoco.core.api.models.entity.CodeEntity; /** * A code item of a code model. @@ -24,6 +24,8 @@ }) public abstract sealed class CodeItem extends CodeEntity permits CodeModule, ComputationalObject, Datatype { + private static final long serialVersionUID = 7089107378955018027L; + @JsonIgnore protected CodeItemRepository codeItemRepository; @@ -61,14 +63,14 @@ public List getAllDataTypes() { } public SortedSet getAllDataTypesAndSelf() { - SortedSet result = new TreeSet<>(getAllDataTypes()); + SortedSet result = new TreeSet<>(this.getAllDataTypes()); result.add(this); return result; } public SortedSet getDeclaredMethods() { SortedSet methods = new TreeSet<>(); - for (CodeItem codeItem : getContent()) { + for (CodeItem codeItem : this.getContent()) { if (codeItem instanceof ControlElement codeMethod) { methods.add(codeMethod); } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodeItemRepository.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodeItemRepository.java index 05dac9d2f..ed4039a1c 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodeItemRepository.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodeItemRepository.java @@ -12,27 +12,30 @@ public class CodeItemRepository implements Serializable { + private static final long serialVersionUID = 7081204548135982601L; + @JsonProperty private SortedMap repository = new TreeMap<>(); @JsonIgnore private boolean initialized = false; public SortedMap getRepository() { - return new TreeMap<>(repository); + return new TreeMap<>(this.repository); } void addCodeItem(CodeItem codeItem) { - repository.put(codeItem.getId(), codeItem); + this.repository.put(codeItem.getId(), codeItem); } boolean containsCodeItem(String id) { - return repository.containsKey(id); + return this.repository.containsKey(id); } CodeItem getCodeItem(String id) { - if (id == null) + if (id == null) { return null; - return repository.get(id); + } + return this.repository.get(id); } public List getCodeItemsFromIds(List codeItemIds) { @@ -40,9 +43,10 @@ public List getCodeItemsFromIds(List codeItemIds) { } public synchronized void init() { - if (initialized) + if (this.initialized) { return; + } this.repository.values().forEach(it -> it.registerCurrentCodeItemRepository(this)); - initialized = true; + this.initialized = true; } } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodeModule.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodeModule.java index a8df6554a..d9145e386 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodeModule.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodeModule.java @@ -22,6 +22,8 @@ @JsonTypeName("CodeModule") public sealed class CodeModule extends CodeItem permits CodeAssembly, CodeCompilationUnit, CodePackage { + private static final long serialVersionUID = -7941299662945801101L; + @JsonProperty private String parentId; @JsonProperty @@ -37,17 +39,17 @@ public CodeModule(CodeItemRepository codeItemRepository, String name, SortedSet< for (var codeItem : content) { this.content.add(codeItem.getId()); } - parentId = null; + this.parentId = null; } @JsonGetter("content") protected List getContentIds() { - return content; + return this.content; } @Override public List getContent() { - return codeItemRepository.getCodeItemsFromIds(content); + return this.codeItemRepository.getCodeItemsFromIds(this.content); } public void setContent(List content) { @@ -66,7 +68,7 @@ public void addContent(List content) { } public CodeModule getParent() { - CodeItem codeItem = codeItemRepository.getCodeItem(parentId); + CodeItem codeItem = this.codeItemRepository.getCodeItem(this.parentId); if (codeItem instanceof CodeModule codeModule) { return codeModule; } @@ -74,49 +76,45 @@ public CodeModule getParent() { } public boolean hasParent() { - return getParent() != null; + return this.getParent() != null; } public void setParent(CodeModule parent) { this.parentId = parent.getId(); - if (!codeItemRepository.containsCodeItem(parentId)) { - codeItemRepository.addCodeItem(parent); + if (!this.codeItemRepository.containsCodeItem(this.parentId)) { + this.codeItemRepository.addCodeItem(parent); } } @Override public SortedSet getAllCompilationUnits() { SortedSet result = new TreeSet<>(); - getContent().forEach(c -> result.addAll(c.getAllCompilationUnits())); + this.getContent().forEach(c -> result.addAll(c.getAllCompilationUnits())); return result; } @Override public SortedSet getAllPackages() { SortedSet result = new TreeSet<>(); - getContent().forEach(c -> result.addAll(c.getAllPackages())); + this.getContent().forEach(c -> result.addAll(c.getAllPackages())); return result; } @Override public boolean equals(Object o) { - if (this == o) + if (this == o) { return true; - if (!(o instanceof CodeModule that)) - return false; - if (!super.equals(o)) - return false; - - if (!Objects.equals(parentId, that.parentId)) + } + if (!(o instanceof CodeModule that) || !super.equals(o) || !Objects.equals(this.parentId, that.parentId)) { return false; - return Objects.equals(content, that.content); + } + return Objects.equals(this.content, that.content); } @Override public int hashCode() { int result = super.hashCode(); - result = 31 * result + (parentId != null ? parentId.hashCode() : 0); - result = 31 * result + (content != null ? content.hashCode() : 0); - return result; + result = 31 * result + (this.parentId != null ? this.parentId.hashCode() : 0); + return 31 * result + (this.content != null ? this.content.hashCode() : 0); } } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodePackage.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodePackage.java index 5973e4fe2..2c31960db 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodePackage.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/CodePackage.java @@ -9,6 +9,8 @@ @JsonTypeName("CodePackage") public final class CodePackage extends CodeModule { + private static final long serialVersionUID = -5224168387357601602L; + @SuppressWarnings("unused") private CodePackage() { // Jackson @@ -24,7 +26,7 @@ public CodePackage(CodeItemRepository codeItemRepository, String name, SortedSet public SortedSet getSubpackages() { SortedSet codePackages = new TreeSet<>(); - for (CodeItem packageElement : getContent()) { + for (CodeItem packageElement : this.getContent()) { if (packageElement instanceof CodePackage codePackage) { codePackages.add(codePackage); } @@ -34,7 +36,7 @@ public SortedSet getSubpackages() { public SortedSet getCompilationUnits() { SortedSet compilationUnits = new TreeSet<>(); - for (CodeItem packageElement : getContent()) { + for (CodeItem packageElement : this.getContent()) { if (packageElement instanceof CodeCompilationUnit compilationUnit) { compilationUnits.add(compilationUnit); } @@ -46,7 +48,7 @@ public SortedSet getCompilationUnits() { public SortedSet getAllPackages() { SortedSet result = new TreeSet<>(); result.add(this); - getContent().forEach(c -> result.addAll(c.getAllPackages())); + this.getContent().forEach(c -> result.addAll(c.getAllPackages())); return result; } } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/ComputationalObject.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/ComputationalObject.java index b4836f975..0bd1bbb66 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/ComputationalObject.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/ComputationalObject.java @@ -10,6 +10,8 @@ @JsonTypeName("ComputationalObject") public sealed class ComputationalObject extends CodeItem permits ControlElement { + private static final long serialVersionUID = -6879811567216500291L; + ComputationalObject() { // Jackson } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/ControlElement.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/ControlElement.java index 1d1e3497f..2a60253e5 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/ControlElement.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/ControlElement.java @@ -6,6 +6,8 @@ @JsonTypeName("ControlElement") public final class ControlElement extends ComputationalObject { + private static final long serialVersionUID = -2733651783905632198L; + @SuppressWarnings("unused") private ControlElement() { // Jackson diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/Datatype.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/Datatype.java index 476b12a4f..b6d2c2e2a 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/Datatype.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/Datatype.java @@ -21,6 +21,8 @@ @JsonTypeName("Datatype") public sealed class Datatype extends CodeItem permits ClassUnit, InterfaceUnit { + private static final long serialVersionUID = -1925023806648753973L; + @JsonProperty private String compilationUnitId; @JsonProperty @@ -44,7 +46,7 @@ public Datatype(CodeItemRepository codeItemRepository, String name) { } public CodeCompilationUnit getCompilationUnit() { - CodeItem codeItem = codeItemRepository.getCodeItem(compilationUnitId); + CodeItem codeItem = this.codeItemRepository.getCodeItem(this.compilationUnitId); if (codeItem instanceof CodeCompilationUnit codeCompilationUnit) { return codeCompilationUnit; } @@ -52,7 +54,7 @@ public CodeCompilationUnit getCompilationUnit() { } public Datatype getParentDatatype() { - CodeItem codeItem = codeItemRepository.getCodeItem(parentDatatypeId); + CodeItem codeItem = this.codeItemRepository.getCodeItem(this.parentDatatypeId); if (codeItem instanceof Datatype datatype) { return datatype; } @@ -60,8 +62,8 @@ public Datatype getParentDatatype() { } public SortedSet getExtendedTypes() { - return extendedDataTypesIds.stream().map(id -> { - CodeItem codeItem = codeItemRepository.getCodeItem(id); + return this.extendedDataTypesIds.stream().map(id -> { + CodeItem codeItem = this.codeItemRepository.getCodeItem(id); if (codeItem instanceof Datatype datatype) { return datatype; } else { @@ -71,8 +73,8 @@ public SortedSet getExtendedTypes() { } public SortedSet getImplementedTypes() { - return implementedDataTypesIds.stream().map(id -> { - CodeItem codeItem = codeItemRepository.getCodeItem(id); + return this.implementedDataTypesIds.stream().map(id -> { + CodeItem codeItem = this.codeItemRepository.getCodeItem(id); if (codeItem instanceof Datatype datatype) { return datatype; } else { @@ -82,8 +84,8 @@ public SortedSet getImplementedTypes() { } public SortedSet getDatatypeReferences() { - return datatypeReferencesIds.stream().map(id -> { - CodeItem codeItem = codeItemRepository.getCodeItem(id); + return this.datatypeReferencesIds.stream().map(id -> { + CodeItem codeItem = this.codeItemRepository.getCodeItem(id); if (codeItem instanceof Datatype datatype) { return datatype; } else { @@ -120,32 +122,28 @@ public void setDatatypeReference(SortedSet datatypeDependencies) { @Override public boolean equals(Object o) { - if (this == o) + if (this == o) { return true; - if (!(o instanceof Datatype datatype)) - return false; - if (!super.equals(o)) - return false; - - if (!Objects.equals(compilationUnitId, datatype.compilationUnitId)) - return false; - if (!Objects.equals(parentDatatypeId, datatype.parentDatatypeId)) + } + if (!(o instanceof Datatype datatype) || !super.equals(o) || !Objects.equals(this.compilationUnitId, datatype.compilationUnitId) || !Objects.equals(this.parentDatatypeId, datatype.parentDatatypeId)) { return false; - if (!Objects.equals(extendedDataTypesIds, datatype.extendedDataTypesIds)) + } + if (!Objects.equals(this.extendedDataTypesIds, datatype.extendedDataTypesIds)) { return false; - if (!Objects.equals(implementedDataTypesIds, datatype.implementedDataTypesIds)) + } + if (!Objects.equals(this.implementedDataTypesIds, datatype.implementedDataTypesIds)) { return false; - return Objects.equals(datatypeReferencesIds, datatype.datatypeReferencesIds); + } + return Objects.equals(this.datatypeReferencesIds, datatype.datatypeReferencesIds); } @Override public int hashCode() { int result = super.hashCode(); - result = 31 * result + (compilationUnitId != null ? compilationUnitId.hashCode() : 0); - result = 31 * result + (parentDatatypeId != null ? parentDatatypeId.hashCode() : 0); - result = 31 * result + (extendedDataTypesIds != null ? extendedDataTypesIds.hashCode() : 0); - result = 31 * result + (implementedDataTypesIds != null ? implementedDataTypesIds.hashCode() : 0); - result = 31 * result + (datatypeReferencesIds != null ? datatypeReferencesIds.hashCode() : 0); - return result; + result = 31 * result + (this.compilationUnitId != null ? this.compilationUnitId.hashCode() : 0); + result = 31 * result + (this.parentDatatypeId != null ? this.parentDatatypeId.hashCode() : 0); + result = 31 * result + (this.extendedDataTypesIds != null ? this.extendedDataTypesIds.hashCode() : 0); + result = 31 * result + (this.implementedDataTypesIds != null ? this.implementedDataTypesIds.hashCode() : 0); + return 31 * result + (this.datatypeReferencesIds != null ? this.datatypeReferencesIds.hashCode() : 0); } } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/InterfaceUnit.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/InterfaceUnit.java index 00132baf0..35cd148c8 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/InterfaceUnit.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/InterfaceUnit.java @@ -13,6 +13,8 @@ @JsonTypeName("InterfaceUnit") public final class InterfaceUnit extends Datatype { + private static final long serialVersionUID = 7746781256077022392L; + @JsonProperty private List content; @@ -31,38 +33,37 @@ public InterfaceUnit(CodeItemRepository codeItemRepository, String name, SortedS @JsonGetter("content") protected List getContentIds() { - return content; + return this.content; } @Override public List getContent() { - return codeItemRepository.getCodeItemsFromIds(content); + return this.codeItemRepository.getCodeItemsFromIds(this.content); } @Override public List getAllDataTypes() { List result = new ArrayList<>(); result.add(this); - getContent().forEach(c -> result.addAll(c.getAllDataTypes())); + this.getContent().forEach(c -> result.addAll(c.getAllDataTypes())); return result; } @Override public boolean equals(Object o) { - if (this == o) + if (this == o) { return true; - if (!(o instanceof InterfaceUnit that)) - return false; - if (!super.equals(o)) + } + if (!(o instanceof InterfaceUnit that) || !super.equals(o)) { return false; + } - return Objects.equals(content, that.content); + return Objects.equals(this.content, that.content); } @Override public int hashCode() { int result = super.hashCode(); - result = 31 * result + (content != null ? content.hashCode() : 0); - return result; + return 31 * result + (this.content != null ? this.content.hashCode() : 0); } } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/ProgrammingLanguage.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/ProgrammingLanguage.java deleted file mode 100644 index 5030f30d6..000000000 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/ProgrammingLanguage.java +++ /dev/null @@ -1,9 +0,0 @@ -/* Licensed under MIT 2023. */ -package edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code; - -/** - * Supported programming languages. - */ -public enum ProgrammingLanguage { - JAVA, SHELL -} diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/ProgrammingLanguages.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/ProgrammingLanguages.java new file mode 100644 index 000000000..342087dd1 --- /dev/null +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/arcotl/code/ProgrammingLanguages.java @@ -0,0 +1,14 @@ +/* Licensed under MIT 2023. */ +package edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code; + +/** + * Supported programming languages. + */ +public final class ProgrammingLanguages { + private ProgrammingLanguages() { + throw new IllegalAccessError(); + } + + public static final String JAVA = "JAVA"; + public static final String SHELL = "SHELL"; +} diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ArchitectureEntity.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/entity/ArchitectureEntity.java similarity index 67% rename from framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ArchitectureEntity.java rename to framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/entity/ArchitectureEntity.java index 121adfa94..6241e1199 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/ArchitectureEntity.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/entity/ArchitectureEntity.java @@ -1,7 +1,9 @@ /* Licensed under MIT 2024. */ -package edu.kit.kastel.mcse.ardoco.core.api.models; +package edu.kit.kastel.mcse.ardoco.core.api.models.entity; public abstract non-sealed class ArchitectureEntity extends Entity { + private static final long serialVersionUID = 5118724938904048363L; + protected ArchitectureEntity(String name) { super(name); } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/CodeEntity.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/entity/CodeEntity.java similarity index 64% rename from framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/CodeEntity.java rename to framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/entity/CodeEntity.java index 01e1e8af3..736fe9f96 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/CodeEntity.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/entity/CodeEntity.java @@ -1,7 +1,9 @@ /* Licensed under MIT 2024. */ -package edu.kit.kastel.mcse.ardoco.core.api.models; +package edu.kit.kastel.mcse.ardoco.core.api.models.entity; public non-sealed class CodeEntity extends Entity { + private static final long serialVersionUID = 5520572653996476974L; + protected CodeEntity(String name) { super(name); } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/entity/Entity.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/entity/Entity.java new file mode 100644 index 000000000..d13194795 --- /dev/null +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/entity/Entity.java @@ -0,0 +1,84 @@ +/* Licensed under MIT 2023-2024. */ +package edu.kit.kastel.mcse.ardoco.core.api.models.entity; + +import java.io.Serializable; +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import edu.kit.kastel.mcse.ardoco.core.common.IdentifierProvider; + +/** + * An entity with a name. Is a model element. + */ +public abstract sealed class Entity implements Serializable, Comparable permits ArchitectureEntity, TextEntity, CodeEntity { + + private static final long serialVersionUID = 5916408204883918465L; + + @JsonProperty + private final String id; + + @JsonProperty + private String name; + + protected Entity() { + // Jackson + this(null); + } + + /** + * Creates a new entity with the specified name. + * + * @param name the name of the entity to be created + */ + protected Entity(String name) { + this(IdentifierProvider.createId(), name); + } + + protected Entity(String name, String id) { + this.id = Objects.requireNonNull(id); + this.name = name; + } + + public String getId() { + return this.id; + } + + /** + * Returns the entity's name. + * + * @return the entity's name + */ + public String getName() { + return this.name; + } + + @Override + public String toString() { + return this.name; + } + + @Override + public int hashCode() { + return Objects.hash(this.id, this.name); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof Entity other)) { + return false; + } + return Objects.equals(this.id, other.id) && Objects.equals(this.name, other.name); + } + + @Override + public int compareTo(Entity o) { + if (this.equals(o)) { + return 0; + } + return this.id.compareTo(o.id); + } +} diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/TextEntity.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/entity/TextEntity.java similarity index 64% rename from framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/TextEntity.java rename to framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/entity/TextEntity.java index 89336a41a..0c93cf5c9 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/TextEntity.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/entity/TextEntity.java @@ -1,7 +1,9 @@ /* Licensed under MIT 2024. */ -package edu.kit.kastel.mcse.ardoco.core.api.models; +package edu.kit.kastel.mcse.ardoco.core.api.models.entity; public non-sealed class TextEntity extends Entity { + private static final long serialVersionUID = 7693834560590279832L; + protected TextEntity(String name) { super(name); } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/EndpointTuple.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/EndpointTuple.java index 5b8661919..e2fde6964 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/EndpointTuple.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/EndpointTuple.java @@ -4,13 +4,15 @@ import java.io.Serializable; import java.util.Objects; -import edu.kit.kastel.mcse.ardoco.core.api.models.Entity; +import edu.kit.kastel.mcse.ardoco.core.api.models.entity.Entity; /** * A tuple of one architecture endpoint and one code endpoint. Every endpoint tuple is a possible candidate for the endpoints of a trace link that connects * corresponding elements of an architecture model and a code model. An endpoint tuple cannot consist of two architecture endpoints or of two code endpoints. */ public class EndpointTuple implements Serializable { + private static final long serialVersionUID = -3671983559151147055L; + private final E1 firstEndpoint; private final E2 secondEndpoint; @@ -24,21 +26,21 @@ public EndpointTuple(E1 firstEndpoint, E2 secondEndpoint) { } public Entity getOtherEndpoint(Entity endpoint) { - if (firstEndpoint.equals(endpoint)) { - return secondEndpoint; + if (this.firstEndpoint.equals(endpoint)) { + return this.secondEndpoint; } - if (secondEndpoint.equals(endpoint)) { - return firstEndpoint; + if (this.secondEndpoint.equals(endpoint)) { + return this.firstEndpoint; } throw new IllegalArgumentException("Endpoint tuple must contain given endpoint"); } public boolean hasEndpoint(Entity endpoint) { - return firstEndpoint.equals(endpoint) || secondEndpoint.equals(endpoint); + return this.firstEndpoint.equals(endpoint) || this.secondEndpoint.equals(endpoint); } public boolean hasEndpoint(EndpointTuple endpointTuple) { - return firstEndpoint.equals(endpointTuple.firstEndpoint) || secondEndpoint.equals(endpointTuple.secondEndpoint); + return this.firstEndpoint.equals(endpointTuple.firstEndpoint) || this.secondEndpoint.equals(endpointTuple.secondEndpoint); } @Override @@ -49,25 +51,25 @@ public boolean equals(Object obj) { if (!(obj instanceof EndpointTuple other)) { return false; } - return Objects.equals(firstEndpoint, other.firstEndpoint) && Objects.equals(secondEndpoint, other.secondEndpoint); + return Objects.equals(this.firstEndpoint, other.firstEndpoint) && Objects.equals(this.secondEndpoint, other.secondEndpoint); } @Override public String toString() { - return "First Endpoint: " + firstEndpoint + ", Second Endpoint: " + secondEndpoint; + return "First Endpoint: " + this.firstEndpoint + ", Second Endpoint: " + this.secondEndpoint; } public E1 firstEndpoint() { - return firstEndpoint; + return this.firstEndpoint; } public E2 secondEndpoint() { - return secondEndpoint; + return this.secondEndpoint; } @Override public int hashCode() { - return Objects.hash(firstEndpoint, secondEndpoint); + return Objects.hash(this.firstEndpoint, this.secondEndpoint); } } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/SadCodeTraceLink.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/SadCodeTraceLink.java index ed1f1b6bd..b282d7076 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/SadCodeTraceLink.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/SadCodeTraceLink.java @@ -6,6 +6,8 @@ public class SadCodeTraceLink extends TraceLink { + private static final long serialVersionUID = -1099702076674008083L; + public SadCodeTraceLink(SentenceEntity e1, CodeCompilationUnit e2) { super(e1, e2); } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/SadSamTraceLink.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/SadSamTraceLink.java index 89f709c97..7e91f16db 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/SadSamTraceLink.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/SadSamTraceLink.java @@ -3,8 +3,9 @@ import java.util.Objects; -import edu.kit.kastel.mcse.ardoco.core.api.models.ArchitectureEntity; -import edu.kit.kastel.mcse.ardoco.core.api.models.ModelInstance; +import edu.kit.kastel.mcse.ardoco.core.api.connectiongenerator.InstanceLink; +import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy.ModelInstance; +import edu.kit.kastel.mcse.ardoco.core.api.models.entity.ArchitectureEntity; import edu.kit.kastel.mcse.ardoco.core.api.text.Sentence; import edu.kit.kastel.mcse.ardoco.core.api.text.SentenceEntity; import edu.kit.kastel.mcse.ardoco.core.api.text.Word; @@ -15,16 +16,18 @@ */ public class SadSamTraceLink extends TraceLink { + private static final long serialVersionUID = -4902602672085469964L; + private final Sentence sentence; - private final ModelInstance modelInstance; + private final ArchitectureEntity architectureEntity; /** * Create a trace link based on a {@link Sentence} and a concrete {@link ModelInstance} . */ - public SadSamTraceLink(Sentence sentence, ModelInstance modelInstance) { + public SadSamTraceLink(Sentence sentence, ArchitectureEntity modelInstance) { super(new SentenceEntity(sentence), modelInstance); this.sentence = sentence; - this.modelInstance = modelInstance; + this.architectureEntity = modelInstance; } /** @@ -33,7 +36,7 @@ public SadSamTraceLink(Sentence sentence, ModelInstance modelInstance) { * @return sentence number of the word that the trace link is based on. */ public int getSentenceNumber() { - return sentence.getSentenceNumber(); + return this.sentence.getSentenceNumber(); } /** @@ -42,7 +45,7 @@ public int getSentenceNumber() { * @return the sentence of the word that the trace link is based on. */ public Sentence getSentence() { - return sentence; + return this.sentence; } /** @@ -50,8 +53,8 @@ public Sentence getSentence() { * * @return Uid of the model element that the trace link is based on. */ - public String getModelElementUid() { - return modelInstance.getUid(); + public String getArchitectureEntityId() { + return this.architectureEntity.getId(); } /** @@ -60,16 +63,16 @@ public String getModelElementUid() { @Override public boolean equals(Object obj) { if (obj instanceof SadSamTraceLink other) { - var otherId = other.getModelElementUid(); + var otherId = other.getArchitectureEntityId(); var otherSentenceNo = other.getSentenceNumber(); - return getModelElementUid().equals(otherId) && getSentenceNumber() == otherSentenceNo; + return this.getArchitectureEntityId().equals(otherId) && this.getSentenceNumber() == otherSentenceNo; } return false; } @Override public int hashCode() { - return Objects.hash(getModelElementUid(), getSentenceNumber()); + return Objects.hash(this.getArchitectureEntityId(), this.getSentenceNumber()); } } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/SamCodeTraceLink.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/SamCodeTraceLink.java index c71512188..46ca1512a 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/SamCodeTraceLink.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/SamCodeTraceLink.java @@ -3,9 +3,9 @@ import java.util.Objects; -import edu.kit.kastel.mcse.ardoco.core.api.models.ArchitectureEntity; import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.ArchitectureItem; import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.CodeCompilationUnit; +import edu.kit.kastel.mcse.ardoco.core.api.models.entity.ArchitectureEntity; /** * A trace link between exactly one architecture endpoint and exactly one code @@ -14,6 +14,8 @@ */ public class SamCodeTraceLink extends TraceLink { + private static final long serialVersionUID = -7683024763031647537L; + /** * Creates a new trace link between an architecture endpoint and a code endpoint * as given in the specified endpoint tuple. @@ -27,7 +29,7 @@ public SamCodeTraceLink(ArchitectureItem architectureEndpoint, CodeCompilationUn @Override public int hashCode() { - return Objects.hash(getEndpointTuple()); + return Objects.hash(this.getEndpointTuple()); } @Override @@ -38,11 +40,11 @@ public boolean equals(Object obj) { if (!(obj instanceof SamCodeTraceLink other)) { return false; } - return Objects.equals(getEndpointTuple(), other.getEndpointTuple()); + return Objects.equals(this.getEndpointTuple(), other.getEndpointTuple()); } @Override public String toString() { - return getEndpointTuple().toString(); + return this.getEndpointTuple().toString(); } } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/TraceLink.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/TraceLink.java index 94b1cab53..8a40b689f 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/TraceLink.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/TraceLink.java @@ -1,12 +1,16 @@ /* Licensed under MIT 2023-2024. */ package edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks; +import java.io.Serial; import java.io.Serializable; import java.util.Objects; -import edu.kit.kastel.mcse.ardoco.core.api.models.Entity; +import edu.kit.kastel.mcse.ardoco.core.api.models.entity.Entity; public abstract class TraceLink implements Serializable { + @Serial + private static final long serialVersionUID = -2363643561606530433L; + private final E1 endpoint1; private final E2 endpoint2; @@ -21,20 +25,20 @@ protected TraceLink(E1 firstEndpoint, E2 secondEndpoint) { * @return the endpoint tuple of this trace link */ public EndpointTuple getEndpointTuple() { - return new EndpointTuple<>(endpoint1, endpoint2); + return new EndpointTuple<>(this.endpoint1, this.endpoint2); } public E1 getFirstEndpoint() { - return endpoint1; + return this.endpoint1; } public E2 getSecondEndpoint() { - return endpoint2; + return this.endpoint2; } @Override public int hashCode() { - return Objects.hash(endpoint1, endpoint2); + return Objects.hash(this.endpoint1, this.endpoint2); } @Override @@ -45,11 +49,11 @@ public boolean equals(Object obj) { if (!(obj instanceof TraceLink other)) { return false; } - return Objects.equals(endpoint1, other.endpoint1) && Objects.equals(endpoint2, other.endpoint2); + return Objects.equals(this.endpoint1, other.endpoint1) && Objects.equals(this.endpoint2, other.endpoint2); } @Override public String toString() { - return getEndpointTuple().toString(); + return this.getEndpointTuple().toString(); } } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/TransitiveTraceLink.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/TransitiveTraceLink.java index 944524084..8f9b0affa 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/TransitiveTraceLink.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/models/tracelinks/TransitiveTraceLink.java @@ -4,10 +4,12 @@ import java.util.Objects; import java.util.Optional; -import edu.kit.kastel.mcse.ardoco.core.api.models.Entity; +import edu.kit.kastel.mcse.ardoco.core.api.models.entity.Entity; public final class TransitiveTraceLink extends TraceLink { + private static final long serialVersionUID = 3781827633038556211L; + private final TraceLink firstTraceLink; private final TraceLink secondTraceLink; @@ -19,7 +21,7 @@ private TransitiveTraceLink(TraceLink firstTraceLink, TraceLink seco public static Optional> createTransitiveTraceLink( TraceLink firstTraceLink, TraceLink secondTraceLink) { - if (isValidTransitiveTraceLink(firstTraceLink, secondTraceLink)) { + if (TransitiveTraceLink.isValidTransitiveTraceLink(firstTraceLink, secondTraceLink)) { return Optional.of(new TransitiveTraceLink<>(firstTraceLink, secondTraceLink)); } return Optional.empty(); @@ -32,16 +34,16 @@ public static boolean isValidTransitiveTraceLink(TraceLink firstTraceLink, } public TraceLink getFirstTraceLink() { - return firstTraceLink; + return this.firstTraceLink; } public TraceLink getSecondTraceLink() { - return secondTraceLink; + return this.secondTraceLink; } @Override public int hashCode() { - return Objects.hash(getEndpointTuple()); + return Objects.hash(this.getEndpointTuple()); } @Override @@ -52,8 +54,8 @@ public boolean equals(Object obj) { if (!(obj instanceof TransitiveTraceLink other)) { return false; } - return Objects.equals(getFirstTraceLink(), other.getFirstTraceLink()) && // - Objects.equals(getSecondTraceLink(), other.getSecondTraceLink()) && // - Objects.equals(getEndpointTuple(), other.getEndpointTuple()); + return Objects.equals(this.getFirstTraceLink(), other.getFirstTraceLink()) && // + Objects.equals(this.getSecondTraceLink(), other.getSecondTraceLink()) && // + Objects.equals(this.getEndpointTuple(), other.getEndpointTuple()); } } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/recommendationgenerator/RecommendationStateStrategy.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/recommendationgenerator/RecommendationStateStrategy.java index e2a606683..509476aea 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/recommendationgenerator/RecommendationStateStrategy.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/recommendationgenerator/RecommendationStateStrategy.java @@ -4,7 +4,7 @@ import java.io.Serializable; public interface RecommendationStateStrategy extends Serializable { - boolean areRITypesSimilar(String typeA, String typeB); + boolean areRecommendedInstanceTypesSimilar(String typeA, String typeB); - boolean areRINamesSimilar(String nameA, String nameB); + boolean areRecommendedInstanceNamesSimilar(String nameA, String nameB); } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/recommendationgenerator/RecommendedInstance.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/recommendationgenerator/RecommendedInstance.java index 60ef17688..5c7fb5158 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/recommendationgenerator/RecommendedInstance.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/recommendationgenerator/RecommendedInstance.java @@ -4,7 +4,7 @@ import org.eclipse.collections.api.list.ImmutableList; import org.eclipse.collections.api.set.sorted.ImmutableSortedSet; -import edu.kit.kastel.mcse.ardoco.core.api.models.TextEntity; +import edu.kit.kastel.mcse.ardoco.core.api.models.entity.TextEntity; import edu.kit.kastel.mcse.ardoco.core.api.textextraction.NounMapping; import edu.kit.kastel.mcse.ardoco.core.pipeline.agent.Claimant; @@ -13,6 +13,8 @@ */ public abstract class RecommendedInstance extends TextEntity { + private static final long serialVersionUID = -5422301094494768943L; + protected RecommendedInstance(String name, String id) { super(name, id); } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/text/NlpInformant.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/text/NlpInformant.java index a03e90dbe..9f98f9f24 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/text/NlpInformant.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/text/NlpInformant.java @@ -9,6 +9,8 @@ */ public abstract class NlpInformant extends Informant { + private static final long serialVersionUID = 7456517198218574644L; + protected NlpInformant(String id, DataRepository dataRepository) { super(id, dataRepository); } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/text/SentenceEntity.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/text/SentenceEntity.java index a5195fb55..d756ab0b6 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/text/SentenceEntity.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/text/SentenceEntity.java @@ -3,10 +3,12 @@ import java.util.Objects; -import edu.kit.kastel.mcse.ardoco.core.api.models.TextEntity; +import edu.kit.kastel.mcse.ardoco.core.api.models.entity.TextEntity; public final class SentenceEntity extends TextEntity { + private static final long serialVersionUID = 7370112901785822767L; + private final Sentence sentence; public SentenceEntity(Sentence sentence) { @@ -15,21 +17,23 @@ public SentenceEntity(Sentence sentence) { } public Sentence getSentence() { - return sentence; + return this.sentence; } @Override public boolean equals(Object o) { - if (this == o) + if (this == o) { return true; - if (o == null || getClass() != o.getClass()) + } + if (o == null || this.getClass() != o.getClass()) { return false; + } SentenceEntity that = (SentenceEntity) o; - return Objects.equals(sentence, that.sentence); + return Objects.equals(this.sentence, that.sentence); } @Override public int hashCode() { - return Objects.hash(sentence); + return Objects.hash(this.sentence); } } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/common/Internal.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/common/Internal.java index 1d5b567bb..a05a573d2 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/common/Internal.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/common/Internal.java @@ -13,6 +13,6 @@ */ @Documented @Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.METHOD, ElementType.TYPE }) +@Target({ ElementType.METHOD, ElementType.TYPE, ElementType.CONSTRUCTOR }) public @interface Internal { } diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/common/util/CommonUtilities.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/common/util/CommonUtilities.java index af434776d..7b9d87011 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/common/util/CommonUtilities.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/common/util/CommonUtilities.java @@ -22,7 +22,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import edu.kit.kastel.mcse.ardoco.core.api.models.LegacyModelExtractionState; +import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy.LegacyModelExtractionState; import edu.kit.kastel.mcse.ardoco.core.api.recommendationgenerator.RecommendationState; import edu.kit.kastel.mcse.ardoco.core.api.recommendationgenerator.RecommendedInstance; import edu.kit.kastel.mcse.ardoco.core.api.text.DependencyTag; diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/common/util/SimilarityUtils.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/common/util/SimilarityUtils.java index ea698edeb..e5b7b06c6 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/common/util/SimilarityUtils.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/common/util/SimilarityUtils.java @@ -13,7 +13,7 @@ import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.api.map.sorted.ImmutableSortedMap; -import edu.kit.kastel.mcse.ardoco.core.api.models.ModelInstance; +import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy.ModelInstance; import edu.kit.kastel.mcse.ardoco.core.api.recommendationgenerator.RecommendedInstance; import edu.kit.kastel.mcse.ardoco.core.api.text.PhraseType; import edu.kit.kastel.mcse.ardoco.core.api.text.Word; diff --git a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/common/util/TraceLinkUtilities.java b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/common/util/TraceLinkUtilities.java index cd5d1baa6..269228c1f 100644 --- a/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/common/util/TraceLinkUtilities.java +++ b/framework/common/src/main/java/edu/kit/kastel/mcse/ardoco/core/common/util/TraceLinkUtilities.java @@ -5,8 +5,8 @@ import org.eclipse.collections.api.list.ImmutableList; import org.eclipse.collections.api.list.MutableList; -import edu.kit.kastel.mcse.ardoco.core.api.models.ArchitectureEntity; import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.CodeCompilationUnit; +import edu.kit.kastel.mcse.ardoco.core.api.models.entity.ArchitectureEntity; import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.EndpointTuple; import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.TraceLink; import edu.kit.kastel.mcse.ardoco.core.api.text.SentenceEntity; diff --git a/pipeline-core/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/output/ArDoCoResult.java b/pipeline-core/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/output/ArDoCoResult.java index 0d03ab5e3..be54548a4 100644 --- a/pipeline-core/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/output/ArDoCoResult.java +++ b/pipeline-core/src/main/java/edu/kit/kastel/mcse/ardoco/core/api/output/ArDoCoResult.java @@ -24,12 +24,12 @@ import edu.kit.kastel.mcse.ardoco.core.api.inconsistency.InconsistentSentence; import edu.kit.kastel.mcse.ardoco.core.api.inconsistency.ModelInconsistency; import edu.kit.kastel.mcse.ardoco.core.api.inconsistency.TextInconsistency; -import edu.kit.kastel.mcse.ardoco.core.api.models.ArchitectureEntity; -import edu.kit.kastel.mcse.ardoco.core.api.models.LegacyModelExtractionState; import edu.kit.kastel.mcse.ardoco.core.api.models.Metamodel; -import edu.kit.kastel.mcse.ardoco.core.api.models.ModelInstance; import edu.kit.kastel.mcse.ardoco.core.api.models.ModelStates; +import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy.LegacyModelExtractionState; +import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy.ModelInstance; import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.code.CodeCompilationUnit; +import edu.kit.kastel.mcse.ardoco.core.api.models.entity.ArchitectureEntity; import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.SadSamTraceLink; import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.SamCodeTraceLink; import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.TraceLink; @@ -57,7 +57,7 @@ public record ArDoCoResult(DataRepository dataRepository) { * @return the name of the project the results are based on. */ public String getProjectName() { - return DataRepositoryHelper.getProjectPipelineData(dataRepository).getProjectName(); + return DataRepositoryHelper.getProjectPipelineData(this.dataRepository).getProjectName(); } /** @@ -66,8 +66,8 @@ public String getProjectName() { * @param modelId the ID of the model that should be traced * @return Trace links for the model with the given id */ - public ImmutableSet> getTraceLinksForModel(String modelId) { - ConnectionState connectionState = getConnectionState(modelId); + public ImmutableSet> getTraceLinksForModel(Metamodel modelId) { + ConnectionState connectionState = this.getConnectionState(modelId); if (connectionState != null) { return connectionState.getTraceLinks(); } @@ -80,11 +80,11 @@ public ImmutableSet> getTraceLinks * @param modelId the ID of the model that should be traced * @return Trace links for the model with the given id as Strings */ - public ImmutableSortedSet getTraceLinksForModelAsStrings(String modelId) { + public ImmutableSortedSet getTraceLinksForModelAsStrings(Metamodel modelId) { var formatString = "%s,%d"; - return getTraceLinksForModel(modelId).collect(tl -> String.format(formatString, tl.getSecondEndpoint().getId(), tl.getFirstEndpoint() - .getSentence() - .getSentenceNumber() + 1)).toImmutableSortedSet(); + return this.getTraceLinksForModel(modelId) + .collect(tl -> String.format(formatString, tl.getSecondEndpoint().getId(), tl.getFirstEndpoint().getSentence().getSentenceNumber() + 1)) + .toImmutableSortedSet(); } /** @@ -95,9 +95,10 @@ public ImmutableSortedSet getTraceLinksForModelAsStrings(String modelId) public ImmutableList> getAllTraceLinks() { MutableSet> traceLinks = Sets.mutable.empty(); - for (var modelId : getModelIds()) { - if (getModelState(modelId).getMetamodel() == Metamodel.ARCHITECTURE) - traceLinks.addAll(getTraceLinksForModel(modelId).castToCollection()); + for (var modelId : this.getModelIds()) { + if (this.getModelState(modelId).getMetamodel() == Metamodel.ARCHITECTURE) { + traceLinks.addAll(this.getTraceLinksForModel(modelId).castToCollection()); + } } return traceLinks.toImmutableList(); } @@ -108,7 +109,8 @@ public ImmutableList> getAllTraceL * @return Trace links as Strings */ public List getAllTraceLinksAsBeautifiedStrings() { - return getAllTraceLinks().toSortedList(Comparator.comparingInt(tl -> tl.getFirstEndpoint().getSentence().getSentenceNumber())) + return this.getAllTraceLinks() + .toSortedList(Comparator.comparingInt(tl -> tl.getFirstEndpoint().getSentence().getSentenceNumber())) .collect(ArDoCoResult::formatTraceLinksHumanReadable); } @@ -130,9 +132,10 @@ private static String formatTraceLinksHumanReadable(TraceLink> getSamCodeTraceLinks() { - var samCodeTraceabilityState = getCodeTraceabilityState(); - if (samCodeTraceabilityState != null) + var samCodeTraceabilityState = this.getCodeTraceabilityState(); + if (samCodeTraceabilityState != null) { return samCodeTraceabilityState.getSamCodeTraceLinks().toList(); + } return List.of(); } @@ -142,9 +145,10 @@ public List> getSamCodeTraceL * @return the list of {@link TransitiveTraceLink TransitiveTraceLinks}. */ public List> getSadCodeTraceLinks() { - var samCodeTraceabilityState = getCodeTraceabilityState(); - if (samCodeTraceabilityState != null) + var samCodeTraceabilityState = this.getCodeTraceabilityState(); + if (samCodeTraceabilityState != null) { return samCodeTraceabilityState.getSadCodeTraceLinks().toList(); + } return List.of(); } @@ -154,8 +158,8 @@ public List> getSadCodeTraceLinks * @param modelId the ID of the model * @return Inconsistencies for the model */ - public ImmutableList getAllInconsistenciesForModel(String modelId) { - InconsistencyState inconsistencyState = getInconsistencyState(modelId); + public ImmutableList getAllInconsistenciesForModel(Metamodel modelId) { + InconsistencyState inconsistencyState = this.getInconsistencyState(modelId); if (inconsistencyState != null) { return inconsistencyState.getInconsistencies(); } @@ -170,8 +174,8 @@ public ImmutableList getAllInconsistenciesForModel(String modelId * @param Type-parameter of the inconsistency * @return Inconsistencies for the model with the given type */ - public ImmutableList getInconsistenciesOfTypeForModel(String modelId, Class inconsistencyType) { - return getAllInconsistenciesForModel(modelId).select(i -> inconsistencyType.isAssignableFrom(i.getClass())).collect(inconsistencyType::cast); + public ImmutableList getInconsistenciesOfTypeForModel(Metamodel modelId, Class inconsistencyType) { + return this.getAllInconsistenciesForModel(modelId).select(i -> inconsistencyType.isAssignableFrom(i.getClass())).collect(inconsistencyType::cast); } /** @@ -181,8 +185,8 @@ public ImmutableList getInconsistenciesOfTypeForMod */ public ImmutableList getAllInconsistencies() { MutableList inconsistencies = Lists.mutable.empty(); - for (var model : getModelIds()) { - inconsistencies.addAll(getAllInconsistenciesForModel(model).castToCollection()); + for (var model : this.getModelIds()) { + inconsistencies.addAll(this.getAllInconsistenciesForModel(model).castToCollection()); } return inconsistencies.toImmutable(); } @@ -193,7 +197,7 @@ public ImmutableList getAllInconsistencies() { * @return all found TextInconsistencies */ public ImmutableList getAllTextInconsistencies() { - var inconsistencies = getAllInconsistencies(); + var inconsistencies = this.getAllInconsistencies(); return inconsistencies.select(i -> TextInconsistency.class.isAssignableFrom(i.getClass())).collect(TextInconsistency.class::cast); } @@ -203,7 +207,7 @@ public ImmutableList getAllTextInconsistencies() { * @return all found ModelInconsistencies */ public ImmutableList getAllModelInconsistencies() { - var inconsistencies = getAllInconsistencies(); + var inconsistencies = this.getAllInconsistencies(); return inconsistencies.select(i -> ModelInconsistency.class.isAssignableFrom(i.getClass())).collect(ModelInconsistency.class::cast); } @@ -215,14 +219,14 @@ public ImmutableList getAllModelInconsistencies() { public ImmutableList getInconsistentSentences() { Map incSentenceMap = new LinkedHashMap<>(); - var inconsistencies = getAllTextInconsistencies(); + var inconsistencies = this.getAllTextInconsistencies(); for (var inconsistency : inconsistencies) { int sentenceNo = inconsistency.getSentenceNumber(); var incSentence = incSentenceMap.get(sentenceNo); if (incSentence != null) { incSentence.addInconsistency(inconsistency); } else { - var sentence = getSentence(sentenceNo); + var sentence = this.getSentence(sentenceNo); incSentence = new InconsistentSentence(sentence, inconsistency); incSentenceMap.put(sentenceNo, incSentence); } @@ -239,7 +243,7 @@ public ImmutableList getInconsistentSentences() { * @return Sentence with the given number */ public Sentence getSentence(int sentenceNo) { - return getText().getSentences().detect(s -> s.getSentenceNumberForOutput() == sentenceNo); + return this.getText().getSentences().detect(s -> s.getSentenceNumberForOutput() == sentenceNo); } /** @@ -248,13 +252,13 @@ public Sentence getSentence(int sentenceNo) { * @param modelId the ID of the model * @return the connection state or null, if there is no {@link ConnectionState} for the given model ID */ - public ConnectionState getConnectionState(String modelId) { - if (DataRepositoryHelper.hasConnectionStates(dataRepository)) { - var connectionStates = DataRepositoryHelper.getConnectionStates(dataRepository); - var modelState = getModelState(modelId); + public ConnectionState getConnectionState(Metamodel modelId) { + if (DataRepositoryHelper.hasConnectionStates(this.dataRepository)) { + var connectionStates = DataRepositoryHelper.getConnectionStates(this.dataRepository); + var modelState = this.getModelState(modelId); return connectionStates.getConnectionState(modelState.getMetamodel()); } - logger.warn("No ConnectionState found."); + ArDoCoResult.logger.warn("No ConnectionState found."); return null; } @@ -264,13 +268,13 @@ public ConnectionState getConnectionState(String modelId) { * @param modelId the ID of the model * @return the inconsistency state or null, if there is no {@link InconsistencyState} for the given model ID */ - public InconsistencyState getInconsistencyState(String modelId) { - if (DataRepositoryHelper.hasInconsistencyStates(dataRepository)) { - var inconsistencyStates = DataRepositoryHelper.getInconsistencyStates(dataRepository); - var modelState = getModelState(modelId); + public InconsistencyState getInconsistencyState(Metamodel modelId) { + if (DataRepositoryHelper.hasInconsistencyStates(this.dataRepository)) { + var inconsistencyStates = DataRepositoryHelper.getInconsistencyStates(this.dataRepository); + var modelState = this.getModelState(modelId); return inconsistencyStates.getInconsistencyState(modelState.getMetamodel()); } - logger.warn("No InconsistencyState found."); + ArDoCoResult.logger.warn("No InconsistencyState found."); return null; } @@ -280,10 +284,10 @@ public InconsistencyState getInconsistencyState(String modelId) { * @return the {@link CodeTraceabilityState} state or null, if there is no {@link CodeTraceabilityState} for the given model ID */ public CodeTraceabilityState getCodeTraceabilityState() { - if (DataRepositoryHelper.hasCodeTraceabilityState(dataRepository)) { - return DataRepositoryHelper.getCodeTraceabilityState(dataRepository); + if (DataRepositoryHelper.hasCodeTraceabilityState(this.dataRepository)) { + return DataRepositoryHelper.getCodeTraceabilityState(this.dataRepository); } - logger.warn("No SamCodeTraceabilityState found."); + ArDoCoResult.logger.warn("No SamCodeTraceabilityState found."); return null; } @@ -293,7 +297,7 @@ public CodeTraceabilityState getCodeTraceabilityState() { * @return the ModelStates */ private ModelStates getModelStates() { - return DataRepositoryHelper.getModelStatesData(dataRepository); + return DataRepositoryHelper.getModelStatesData(this.dataRepository); } /** @@ -301,8 +305,8 @@ private ModelStates getModelStates() { * * @return list of all model IDs */ - public List getModelIds() { - ModelStates modelStates = getModelStates(); + public List getModelIds() { + ModelStates modelStates = this.getModelStates(); return Lists.mutable.ofAll(modelStates.modelIds()); } @@ -312,8 +316,8 @@ public List getModelIds() { * @param modelId the ID of the model * @return the LegacyModelExtractionState */ - public LegacyModelExtractionState getModelState(String modelId) { - ModelStates modelStates = getModelStates(); + public LegacyModelExtractionState getModelState(Metamodel modelId) { + ModelStates modelStates = this.getModelStates(); return modelStates.getModelExtractionState(modelId); } @@ -323,7 +327,7 @@ public LegacyModelExtractionState getModelState(String modelId) { * @return the TextState */ public TextState getTextState() { - return DataRepositoryHelper.getTextState(dataRepository); + return DataRepositoryHelper.getTextState(this.dataRepository); } /** @@ -333,16 +337,16 @@ public TextState getTextState() { * @return the recommendation state or null, if there is none */ public RecommendationState getRecommendationState(Metamodel metamodel) { - if (DataRepositoryHelper.hasRecommendationStates(dataRepository)) { - var recommendationStates = DataRepositoryHelper.getRecommendationStates(dataRepository); + if (DataRepositoryHelper.hasRecommendationStates(this.dataRepository)) { + var recommendationStates = DataRepositoryHelper.getRecommendationStates(this.dataRepository); return recommendationStates.getRecommendationState(metamodel); } - logger.warn("No RecommendationState found"); + ArDoCoResult.logger.warn("No RecommendationState found"); return null; } public PreprocessingData getPreprocessingData() { - return dataRepository.getData(PreprocessingData.ID, PreprocessingData.class).orElseThrow(); + return this.dataRepository.getData(PreprocessingData.ID, PreprocessingData.class).orElseThrow(); } /** @@ -351,7 +355,7 @@ public PreprocessingData getPreprocessingData() { * @return the Text */ public Text getText() { - var preprocessingData = getPreprocessingData(); + var preprocessingData = this.getPreprocessingData(); return preprocessingData.getText(); } } diff --git a/pipeline-core/src/main/java/edu/kit/kastel/mcse/ardoco/core/common/util/FilePrinter.java b/pipeline-core/src/main/java/edu/kit/kastel/mcse/ardoco/core/common/util/FilePrinter.java index 067310ef2..8464e4f94 100644 --- a/pipeline-core/src/main/java/edu/kit/kastel/mcse/ardoco/core/common/util/FilePrinter.java +++ b/pipeline-core/src/main/java/edu/kit/kastel/mcse/ardoco/core/common/util/FilePrinter.java @@ -33,15 +33,15 @@ import org.slf4j.LoggerFactory; import edu.kit.kastel.mcse.ardoco.core.api.connectiongenerator.ConnectionState; +import edu.kit.kastel.mcse.ardoco.core.api.connectiongenerator.InstanceLink; import edu.kit.kastel.mcse.ardoco.core.api.inconsistency.Inconsistency; import edu.kit.kastel.mcse.ardoco.core.api.inconsistency.InconsistencyState; import edu.kit.kastel.mcse.ardoco.core.api.inconsistency.InconsistentSentence; import edu.kit.kastel.mcse.ardoco.core.api.inconsistency.ModelInconsistency; -import edu.kit.kastel.mcse.ardoco.core.api.models.ArchitectureEntity; -import edu.kit.kastel.mcse.ardoco.core.api.models.LegacyModelExtractionState; import edu.kit.kastel.mcse.ardoco.core.api.models.Metamodel; -import edu.kit.kastel.mcse.ardoco.core.api.models.ModelInstance; -import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.InstanceLink; +import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy.LegacyModelExtractionState; +import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.legacy.ModelInstance; +import edu.kit.kastel.mcse.ardoco.core.api.models.entity.ArchitectureEntity; import edu.kit.kastel.mcse.ardoco.core.api.models.tracelinks.TraceLink; import edu.kit.kastel.mcse.ardoco.core.api.output.ArDoCoResult; import edu.kit.kastel.mcse.ardoco.core.api.recommendationgenerator.RecommendationState;