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