modified: src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/FamilyOfGeneratedGenerics.java

This commit is contained in:
AluAli 2020-11-06 16:33:05 +01:00
parent 70b6c35731
commit 0550f73ef7

View File

@ -185,10 +185,14 @@ public class FamilyOfGeneratedGenerics {
public static boolean checkForDuplicates(TPHConstraint constraint, List list) {
List<TPHConstraint> tempList = list;
boolean hasSame = false;
for (TPHConstraint tphC: tempList) {
return (constraint.getLeft() == tphC.getLeft() &&
hasSame = constraint.getLeft() == tphC.getLeft() &&
constraint.getRight() == tphC.getRight() &&
constraint.getRel() == tphC.getRel()); //constraint already in ArrayList if true
constraint.getRel() == tphC.getRel(); //constraint already in ArrayList if
// System.out.println(hasSame);
if (hasSame)
return true;
}
return false;
}
@ -196,22 +200,23 @@ public class FamilyOfGeneratedGenerics {
public static List<TPHConstraint> buildTransitiveClosure(List list) {
List<TPHConstraint> iterList = list;
List<TPHConstraint> runList = list;
List<TPHConstraint> tcList = new ArrayList<>();
List<TPHConstraint> tcList = list;
boolean addedConToList = false;
for (TPHConstraint cons: iterList) {
for (TPHConstraint cons2: runList) {
if(cons.getRight() == cons2.getLeft()) {
for (TPHConstraint tcCons: tcList) {
if (!checkForDuplicates(tcCons,tcList)) {
tcList.add(new TPHConstraint(cons.getLeft(), cons2.getRight(), Relation.EXTENDS)); //Duplikate? dürfte nicht sein -> checken
addedConToList = true;
if (addedConToList) {
list.add(new TPHConstraint(cons.getLeft(), cons2.getRight(), Relation.EXTENDS));
buildTransitiveClosure(list);
}
TPHConstraint consToAdd = new TPHConstraint(cons.getLeft(), cons2.getRight(), Relation.EXTENDS);
// System.out.println(consToAdd);
// System.out.println(tcList);
// System.out.println(checkForDuplicates(consToAdd,tcList));
if (!checkForDuplicates(consToAdd,tcList)) {
tcList.add(consToAdd); //Duplikate? dürfte nicht sein -> checken
addedConToList = true;
if (addedConToList) {
buildTransitiveClosure(tcList);
}
//TODO: über aktualisierte Liste laufen wegen Updates -> Rekursion?
}
//TODO: über aktualisierte Liste laufen wegen Updates -> Rekursion?
}
}
}