From 0550f73ef73a3d98bee710289b599163ffcf40b6 Mon Sep 17 00:00:00 2001 From: AluAli Date: Fri, 6 Nov 2020 16:33:05 +0100 Subject: [PATCH] modified: src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/FamilyOfGeneratedGenerics.java --- .../FamilyOfGeneratedGenerics.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/FamilyOfGeneratedGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/FamilyOfGeneratedGenerics.java index c8931c28..c9a458ac 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/FamilyOfGeneratedGenerics.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/FamilyOfGeneratedGenerics.java @@ -185,10 +185,14 @@ public class FamilyOfGeneratedGenerics { public static boolean checkForDuplicates(TPHConstraint constraint, List list) { List 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 buildTransitiveClosure(List list) { List iterList = list; List runList = list; - List tcList = new ArrayList<>(); + List 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? } } }