1
1
/* Licensed under MIT 2021-2024. */
2
2
package edu .kit .kastel .mcse .ardoco .core .api .stage .connectiongenerator ;
3
3
4
- import java .io .Serializable ;
5
4
import java .util .Arrays ;
6
5
import java .util .LinkedHashSet ;
7
- import java .util .Objects ;
8
6
import java .util .Set ;
9
7
10
8
import org .eclipse .collections .api .factory .Lists ;
13
11
import edu .kit .kastel .mcse .ardoco .core .api .models .arcotl .architecture .legacy .ModelInstance ;
14
12
import edu .kit .kastel .mcse .ardoco .core .api .stage .recommendationgenerator .RecommendedInstance ;
15
13
import edu .kit .kastel .mcse .ardoco .core .api .stage .textextraction .NounMapping ;
14
+ import edu .kit .kastel .mcse .ardoco .core .api .tracelink .TraceLink ;
16
15
import edu .kit .kastel .mcse .ardoco .core .architecture .Deterministic ;
17
16
import edu .kit .kastel .mcse .ardoco .core .common .AggregationFunctions ;
18
17
import edu .kit .kastel .mcse .ardoco .core .data .Confidence ;
22
21
* An InstanceLink defines a link between an {@link RecommendedInstance} and an {@link ModelInstance}.
23
22
*/
24
23
@ Deterministic
25
- public class InstanceLink implements Serializable {
24
+ public class InstanceLink extends TraceLink < RecommendedInstance , ModelInstance > {
26
25
27
26
private static final long serialVersionUID = -8630933950725516269L ;
28
-
29
- private final RecommendedInstance textualInstance ;
30
- private final ModelInstance modelInstance ;
31
27
private final Confidence confidence ;
32
28
33
29
/**
@@ -37,8 +33,7 @@ public class InstanceLink implements Serializable {
37
33
* @param modelInstance the model instance
38
34
*/
39
35
public InstanceLink (RecommendedInstance textualInstance , ModelInstance modelInstance ) {
40
- this .textualInstance = textualInstance ;
41
- this .modelInstance = modelInstance ;
36
+ super (textualInstance , modelInstance );
42
37
this .confidence = new Confidence (AggregationFunctions .AVERAGE );
43
38
}
44
39
@@ -74,58 +69,24 @@ public final double getConfidence() {
74
69
return this .confidence .getConfidence ();
75
70
}
76
71
77
- /**
78
- * Returns the recommended instance.
79
- *
80
- * @return the textual instance
81
- */
82
- public final RecommendedInstance getTextualInstance () {
83
- return this .textualInstance ;
84
- }
85
-
86
- /**
87
- * Returns the model instance.
88
- *
89
- * @return the extracted instance
90
- */
91
- public final ModelInstance getModelInstance () {
92
- return this .modelInstance ;
93
- }
94
-
95
- @ Override
96
- public int hashCode () {
97
- return Objects .hash (this .modelInstance , this .textualInstance );
98
- }
99
-
100
- @ Override
101
- public boolean equals (Object obj ) {
102
- if (this == obj ) {
103
- return true ;
104
- }
105
- if (!(obj instanceof InstanceLink other )) {
106
- return false ;
107
- }
108
- return Objects .equals (this .getModelInstance (), other .getModelInstance ()) && Objects .equals (this .getTextualInstance (), other .getTextualInstance ());
109
- }
110
-
111
72
@ Override
112
73
public String toString () {
113
74
Set <String > names = new LinkedHashSet <>();
114
75
MutableList <Integer > namePositions = Lists .mutable .empty ();
115
76
Set <String > types = new LinkedHashSet <>();
116
77
MutableList <Integer > typePositions = Lists .mutable .empty ();
117
78
118
- for (NounMapping nameMapping : this .textualInstance .getNameMappings ()) {
79
+ for (NounMapping nameMapping : this .getFirstEndpoint () .getNameMappings ()) {
119
80
names .addAll (nameMapping .getSurfaceForms ().castToCollection ());
120
81
namePositions .addAll (nameMapping .getMappingSentenceNo ().castToCollection ());
121
82
}
122
- for (NounMapping typeMapping : this .textualInstance .getTypeMappings ()) {
83
+ for (NounMapping typeMapping : this .getFirstEndpoint () .getTypeMappings ()) {
123
84
types .addAll (typeMapping .getSurfaceForms ().castToCollection ());
124
85
typePositions .addAll (typeMapping .getMappingSentenceNo ().castToCollection ());
125
86
}
126
- return "InstanceMapping [ uid=" + this .modelInstance .getUid () + ", name=" + this .modelInstance .getFullName () + //
127
- ", as=" + String .join (", " , this .modelInstance .getFullType ()) + ", probability=" + this .getConfidence () + ", FOUND: " + //
128
- this .textualInstance .getName () + " : " + this .textualInstance .getType () + ", occurrences= " + //
87
+ return "InstanceMapping [ uid=" + this .getSecondEndpoint () .getUid () + ", name=" + this .getSecondEndpoint () .getFullName () + //
88
+ ", as=" + String .join (", " , this .getSecondEndpoint () .getFullType ()) + ", probability=" + this .getConfidence () + ", FOUND: " + //
89
+ this .getFirstEndpoint () .getName () + " : " + this .getFirstEndpoint () .getType () + ", occurrences= " + //
129
90
"NameVariants: " + names .size () + ": " + names + " sentences{" + Arrays .toString (namePositions .toArray ()) + "}" + //
130
91
", TypeVariants: " + types .size () + ": " + types + "sentences{" + Arrays .toString (typePositions .toArray ()) + "}" + "]" ;
131
92
}
0 commit comments