Skip to content

Commit

Permalink
Cleanup Serializable
Browse files Browse the repository at this point in the history
  • Loading branch information
dfuchss committed Dec 2, 2024
1 parent 4963206 commit 0c5335d
Show file tree
Hide file tree
Showing 22 changed files with 92 additions and 151 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import java.util.List;

import edu.kit.kastel.mcse.ardoco.core.api.models.Metamodel;
import edu.kit.kastel.mcse.ardoco.core.api.models.arcotl.architecture.ArchitectureItem;

/**
Expand All @@ -24,29 +25,33 @@ public ArchitectureModel(List<ArchitectureItem> content) {

@Override
public List<ArchitectureItem> getContent() {
return content;
return this.content;
}

@Override
public List<ArchitectureItem> getEndpoints() {
return getContent();
return this.getContent();
}

@Override
public Metamodel getMetamodel() {
return Metamodel.ARCHITECTURE;
}

@Override
public boolean equals(Object o) {
if (this == o)
if (this == o) {
return true;
if (!(o instanceof ArchitectureModel that))
return false;
if (!super.equals(o))
}
if (!(o instanceof ArchitectureModel that) || !super.equals(o)) {
return false;
return content.equals(that.content);
}
return this.content.equals(that.content);
}

@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + content.hashCode();
return result;
return 31 * result + this.content.hashCode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;

import edu.kit.kastel.mcse.ardoco.core.api.entity.Entity;
import edu.kit.kastel.mcse.ardoco.core.api.models.Metamodel;
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;
Expand Down Expand Up @@ -51,22 +52,27 @@ public CodeModel(CodeItemRepository codeItemRepository, SortedSet<? extends Code
}
}

@Override
public Metamodel getMetamodel() {
return Metamodel.CODE;
}

@JsonGetter("content")
protected List<String> getContentIds() {
initialize();
return content;
this.initialize();
return this.content;
}

@Override
public List<? extends CodeItem> getContent() {
initialize();
return codeItemRepository.getCodeItemsFromIds(content);
this.initialize();
return this.codeItemRepository.getCodeItemsFromIds(this.content);
}

@Override
public List<? extends CodeCompilationUnit> getEndpoints() {
List<CodeCompilationUnit> compilationUnits = new ArrayList<>();
getContent().forEach(c -> compilationUnits.addAll(c.getAllCompilationUnits()));
this.getContent().forEach(c -> compilationUnits.addAll(c.getAllCompilationUnits()));
return compilationUnits;
}

Expand All @@ -77,7 +83,7 @@ public List<? extends CodeCompilationUnit> getEndpoints() {
*/
public List<? extends CodePackage> getAllPackages() {
List<CodePackage> codePackages = new ArrayList<>();
var lContent = getContent();
var lContent = this.getContent();
for (CodeItem c : lContent) {
var allPackages = c.getAllPackages();
for (CodePackage cp : allPackages) {
Expand All @@ -91,31 +97,28 @@ public List<? extends CodePackage> getAllPackages() {
}

private synchronized void initialize() {
if (initialized)
if (this.initialized) {
return;
}
this.codeItemRepository.init();
initialized = true;
this.initialized = true;
}

@Override
public boolean equals(Object o) {
if (this == o)
if (this == o) {
return true;
if (!(o instanceof CodeModel codeModel))
return false;
if (!super.equals(o))
return false;

if (!Objects.equals(codeItemRepository, codeModel.codeItemRepository))
}
if (!(o instanceof CodeModel codeModel) || !super.equals(o) || !Objects.equals(this.codeItemRepository, codeModel.codeItemRepository)) {
return false;
return Objects.equals(content, codeModel.content);
}
return Objects.equals(this.content, codeModel.content);
}

@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (codeItemRepository != null ? codeItemRepository.hashCode() : 0);
result = 31 * result + (content != null ? content.hashCode() : 0);
return result;
result = 31 * result + (this.codeItemRepository != null ? this.codeItemRepository.hashCode() : 0);
return 31 * result + (this.content != null ? this.content.hashCode() : 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.List;

import edu.kit.kastel.mcse.ardoco.core.api.entity.Entity;
import edu.kit.kastel.mcse.ardoco.core.api.models.Metamodel;
import edu.kit.kastel.mcse.ardoco.core.common.IdentifierProvider;

public abstract sealed class Model permits ArchitectureModel, CodeModel {
Expand All @@ -27,4 +28,6 @@ public String getId() {
* @return the endpoints of this model
*/
public abstract List<? extends Entity> getEndpoints();

public abstract Metamodel getMetamodel();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
import edu.kit.kastel.mcse.ardoco.core.api.stage.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;

/**
* An InstanceLink defines a link between an {@link RecommendedInstance} and an {@link ModelInstance}.
*/
@Deterministic
@Internal
public class InstanceLink implements Serializable {

private static final long serialVersionUID = -8630933950725516269L;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/* Licensed under MIT 2024. */
package edu.kit.kastel.mcse.ardoco.core.api.stage.recommendationgenerator;

import java.io.Serializable;

public interface RecommendationStateStrategy extends Serializable {
public interface RecommendationStateStrategy {
boolean areRecommendedInstanceTypesSimilar(String typeA, String typeB);

boolean areRecommendedInstanceNamesSimilar(String nameA, String nameB);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* Licensed under MIT 2022-2024. */
package edu.kit.kastel.mcse.ardoco.core.api.stage.textextraction;

import java.io.Serializable;

public interface NounMappingChangeListener extends Serializable {
/**
* @deprecated should be replaced to make mappings serializable
*/
@Deprecated
public interface NounMappingChangeListener {
void onDelete(NounMapping deletedNounMapping, NounMapping replacement);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* Licensed under MIT 2022-2024. */
package edu.kit.kastel.mcse.ardoco.core.api.stage.textextraction;

import java.io.Serializable;

public interface PhraseMappingChangeListener extends Serializable {
/**
* @deprecated should be replaced to make mappings serializable
*/
@Deprecated
public interface PhraseMappingChangeListener {
void onDelete(PhraseMapping deletedPhraseMapping, PhraseMapping replacement);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

import static edu.kit.kastel.mcse.ardoco.core.common.AggregationFunctions.AVERAGE;

import java.io.Serializable;

import org.eclipse.collections.api.list.ImmutableList;
import org.eclipse.collections.api.map.sorted.ImmutableSortedMap;
import org.eclipse.collections.api.set.sorted.ImmutableSortedSet;
Expand All @@ -18,7 +16,7 @@
* The Interface for strategies for the text state. Responsible for creating {@link NounMapping NounMappings} from their constituent parts in a variety of
* situations.
*/
public interface TextStateStrategy extends Serializable {
public interface TextStateStrategy {
/**
* Aggregation function used to aggregate multiple confidences into a single value
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/* Licensed under MIT 2021-2024. */
package edu.kit.kastel.mcse.ardoco.core.api.text;

import java.io.Serializable;

/**
* All possible dependency tags in the framework.
*/
public enum DependencyTag implements Serializable {
public enum DependencyTag {

/**
* An appositional modifier of an NP is an NP immediately to the right of the first NP that serves to define or
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
/* Licensed under MIT 2022-2024. */
package edu.kit.kastel.mcse.ardoco.core.common;

import java.io.Serializable;
import java.util.Collection;
import java.util.function.ToDoubleFunction;

/**
* A set of various aggregation functions for collections of numbers.
*/
public enum AggregationFunctions implements ToDoubleFunction<Collection<? extends Number>>, Serializable {
public enum AggregationFunctions implements ToDoubleFunction<Collection<? extends Number>> {
/**
* Use the median of the scores as final score.
*/
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@

import java.io.Serializable;

public record Triple<T extends Serializable, U extends Serializable, V extends Serializable>(T first, U second, V third) implements Serializable {
// TODO Make T Serializable (Claimant) ??
public record Triple<T, U extends Serializable, V extends Serializable>(T first, U second, V third) implements Serializable {
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/* Licensed under MIT 2022-2024. */
package edu.kit.kastel.mcse.ardoco.core.pipeline.agent;

import java.io.Serializable;

/**
* This is a marker interface for classes that claim something, i.e., an intermediate result with usually a certain confidence.
*/
// TODO Serializable for Confidence
public interface Claimant extends Serializable {
// TODO Serializable for Confidence ??
public interface Claimant {
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@
import edu.kit.kastel.mcse.ardoco.core.pipeline.AbstractPipelineStep;

public abstract class Informant extends AbstractPipelineStep implements Claimant {
private static final long serialVersionUID = -5249465765417831157L;

protected Informant(String id, DataRepository dataRepository) {
super(id, dataRepository);
}

@Override
protected void before() {
//Nothing by default
// Nothing by default
}

@Override
protected void after() {
//Nothing by default
// Nothing by default
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* initialization before the main processing.
*/
public abstract class PipelineAgent extends Pipeline implements Agent {
private static final long serialVersionUID = -2278691353857150422L;

private final List<? extends Informant> informants;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
* Example {@link PipelineStepData}
*/
public class ProcessedTextData implements PipelineStepData {
private static final long serialVersionUID = -6806096212069462237L;
private List<String> importantTokens = null;

public ProcessedTextData() {
this.importantTokens = null;
}

public List<String> getImportantTokens() {
return importantTokens;
return this.importantTokens;
}

public void setImportantTokens(List<String> importantTokens) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
* Example {@link PipelineStepData}
*/
public class ResultData implements PipelineStepData {
private static final long serialVersionUID = 9183617106768927240L;
private String result = null;

public String getResult() {
return result;
return this.result;
}

public void setResult(String result) {
Expand Down
Loading

0 comments on commit 0c5335d

Please sign in to comment.