From 7cf46b02b7e68f61175f25f94c2eacd115b6bdf3 Mon Sep 17 00:00:00 2001 From: AluAli Date: Fri, 6 Nov 2020 11:24:21 +0100 Subject: [PATCH] modified: src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/FamilyOfGeneratedGenerics.java --- .../FamilyOfGeneratedGenerics.java | 37 +++++++++++++------ 1 file changed, 25 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 fa626c48..97d005fe 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/FamilyOfGeneratedGenerics.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/gGenericsAli/FamilyOfGeneratedGenerics.java @@ -87,13 +87,16 @@ public class FamilyOfGeneratedGenerics { for(TPHConstraint allCons: allConstraints) { for(ClassConstraint cCons: cs_cl) { for(String tph: posOfTphs.keySet()) { - System.out.println("cCons: " + cCons); if( (posOfTphs.get(tph) == PositionFinder.Position.FIELD) || - (posOfTphs.containsKey(cCons.getLeft()) && cCons.getRight() != null) && - allCons.getRight() == null && - allCons.getRel()==Relation.EXTENDS && cCons.getRel()==Relation.EXTENDS) { + (posOfTphs.containsKey(cCons.getRight()) && cCons.getLeft() != null) && + (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); - tempCC.add(new ClassConstraint(allCons.getLeft(), "Object", Relation.EXTENDS)); + ClassConstraint consToAdd = new ClassConstraint(cCons.getRight(), "Object", Relation.EXTENDS); + if (!checkForDuplicates(consToAdd, tempCC)){ + tempCC.add(consToAdd); + } } } } @@ -109,7 +112,7 @@ public class FamilyOfGeneratedGenerics { * {T < .T' | T is a type variable in a type of the method/constructor m in cl_\sigma, (T <. T') \in cs} *//* - public List typeOfTheMethodInClSigma() { // cl_\sigma?? + public static List typeOfTheMethodInClSigma() { // cl_\sigma?? //TODO: return cs_m; } @@ -120,7 +123,7 @@ public class FamilyOfGeneratedGenerics { * {R' <. S | (R <. R'), (S <. S') \in cs_m and (R',S) is in the transitive closure of cs} *//* - public List firstTransitiveSubtypeForMethodTypes() { //transitive closure of cs + public static List firstTransitiveSubtypeForMethodTypes() { //transitive closure of cs //TODO: return cs_m; } @@ -131,7 +134,7 @@ public class FamilyOfGeneratedGenerics { * {R' <. S | (R <. R') \in cs_m, (S <. S') \in cs_cl and (R',S) is in the transitive closure of cs} *//* - public List secondTransitiveSubtypeForMethodTypes() { + public static List secondTransitiveSubtypeForMethodTypes() { //TODO: return cs_m; } @@ -143,7 +146,7 @@ public class FamilyOfGeneratedGenerics { * (\existsnot T': T <. T') \in cs)} *//* - public List hasNoSupertypeForMethodTypes() { + public static List hasNoSupertypeForMethodTypes() { //TODO: return cs_m; } @@ -151,14 +154,24 @@ public class FamilyOfGeneratedGenerics { */ /** * nimm die Menge cs_cl aus cs_m raus - *//* - - public List methodTypesWithoutClassTypes() { + */ +/* + public static List methodTypesWithoutClassTypes() { //TODO: return cs_m; } */ + public static boolean checkForDuplicates(TPHConstraint constraint, List list) { + List tempList = list; + for (TPHConstraint tphC: tempList) { + return (constraint.getLeft() == tphC.getLeft() && + constraint.getRight() == tphC.getRight() && + constraint.getRel() == tphC.getRel()); //constraint already in ArrayList if true + } + return false; + } +