diff --git a/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/ClassConstraint.java b/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/ClassConstraint.java index 7f86e935..fd5ffcae 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/ClassConstraint.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/ClassConstraint.java @@ -3,7 +3,7 @@ package de.dhbwstuttgart.bytecode.gGenericsAli; import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; public class ClassConstraint extends TPHConstraint { - private TPHConstraint constraint; + //private TPHConstraint constraint; public ClassConstraint(String left, String right, Relation rel) { super(left, right, rel); diff --git a/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/FamilyOfGeneratedGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/FamilyOfGeneratedGenerics.java index 97d005fe..96f2cb74 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/FamilyOfGeneratedGenerics.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/FamilyOfGeneratedGenerics.java @@ -15,17 +15,24 @@ public class FamilyOfGeneratedGenerics { public static List getClassConstraints(List cs, HashMap posOfTphs) { //Inputparameter List constraintsSet weg List cs_cl = new ArrayList<>(); - System.out.println("0: " + cs_cl); List classConstraints1 = typeOfANodeOfAField(cs, cs_cl, posOfTphs); - cs_cl.addAll(classConstraints1); - System.out.println("1: " + cs_cl); + for (ClassConstraint cons: classConstraints1) { + if (!checkForDuplicates(cons, cs_cl)) { + cs_cl.add(cons); + } + } List classConstraints2 = transitiveSubtypeForClassTypes(cs, cs_cl); // in Klammer classConstraints1 oder constraintsSet? beides eher - cs_cl.addAll(classConstraints2); - System.out.println("2: " + cs_cl); + for (ClassConstraint cons: classConstraints2) { + if (!checkForDuplicates(cons, cs_cl)) { + cs_cl.add(cons); + } + } List classConstraints3 = hasNoSupertypeForClassTypes(cs, cs_cl, posOfTphs); - cs_cl.addAll(classConstraints3); - System.out.println("3: " + cs_cl); - + for (ClassConstraint cons: classConstraints3) { + if (!checkForDuplicates(cons, cs_cl)) { + cs_cl.add(cons); + } + } return cs_cl; } @@ -49,7 +56,10 @@ public class FamilyOfGeneratedGenerics { if(posOfTphs.containsKey(allCons.getLeft()) && allCons.getRight()!=null && allCons.getRel()==Relation.EXTENDS) { for(String tph: posOfTphs.keySet()) { if(tph == allCons.getLeft() && posOfTphs.get(tph) == PositionFinder.Position.FIELD) { - tempCC.add(new ClassConstraint(allCons.getLeft(), allCons.getRight(), allCons.getRel())); + ClassConstraint consToAdd = new ClassConstraint(allCons.getLeft(), allCons.getRight(), allCons.getRel()); + if (!checkForDuplicates(consToAdd, tempCC)) { + tempCC.add(consToAdd); + } } } } @@ -68,7 +78,10 @@ public class FamilyOfGeneratedGenerics { if(cCons.getLeft() != null && cCons.getRel()==Relation.EXTENDS) { for(TPHConstraint allCons: allConstraints) { if(cCons.getRight() == allCons.getLeft() && allCons.getRight() != null && allCons.getRel()==Relation.EXTENDS){ - tempCC.add(new ClassConstraint(allCons.getLeft(), allCons.getRight(), allCons.getRel())); + ClassConstraint consToAdd = new ClassConstraint(allCons.getLeft(), allCons.getRight(), allCons.getRel()); + if (!checkForDuplicates(consToAdd, tempCC)) { + tempCC.add(consToAdd); + } } } } @@ -92,7 +105,6 @@ public class FamilyOfGeneratedGenerics { (allCons.getLeft() == tph && allCons.getRight() == null) && allCons.getRel()==Relation.EXTENDS && cCons.getRel()==Relation.EXTENDS && cCons.getRight() == tph && allCons.getLeft() == tph) { - System.out.println("C3: " + allCons); ClassConstraint consToAdd = new ClassConstraint(cCons.getRight(), "Object", Relation.EXTENDS); if (!checkForDuplicates(consToAdd, tempCC)){ tempCC.add(consToAdd);