modified: src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java
modified: src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java
This commit is contained in:
parent
ed7cc55139
commit
997d3b9bea
@ -13,7 +13,7 @@ public class FamilyOfGeneratedGenerics {
|
||||
public HashMap<String, PositionFinder.Position> posOfTPHs = new HashMap<>();
|
||||
public FamilyOfGeneratedGenerics(TPHExtractor tphExtractor) {
|
||||
this.allConstraints = tphExtractor.allCons;
|
||||
this.posOfTPHs = positionConverter(tphExtractor);
|
||||
this.posOfTPHs = positionConverter(tphExtractor.allTPHS);
|
||||
}
|
||||
|
||||
public static List<ClassConstraint> getClassConstraints(List<TPHConstraint> cs, HashMap<String, PositionFinder.Position> posOfTphs) { //Inputparameter List<TPHConstraint> constraintsSet weg
|
||||
@ -232,12 +232,12 @@ public class FamilyOfGeneratedGenerics {
|
||||
}
|
||||
|
||||
|
||||
public HashMap<String, PositionFinder.Position> positionConverter(TPHExtractor tphExtractor) {
|
||||
public static HashMap<String, PositionFinder.Position> positionConverter(HashMap<String, Boolean> allTphs) {
|
||||
HashMap<String, PositionFinder.Position> convertedPositions = new HashMap<>();
|
||||
for(String tph: tphExtractor.allTPHS.keySet()) {
|
||||
if(tphExtractor.allTPHS.get(tph)) {
|
||||
for(String tph: allTphs.keySet()) {
|
||||
if(allTphs.get(tph)) { //if true, then tph is a method-TPH
|
||||
convertedPositions.put(tph, PositionFinder.Position.METHOD);
|
||||
} else {
|
||||
} else { // else it is in the class-TPH
|
||||
convertedPositions.put(tph, PositionFinder.Position.FIELD);
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
|
||||
List<ClassConstraint> classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions);
|
||||
System.out.println(classConstraints);
|
||||
assertTrue(classConstraints.size() == 2);
|
||||
//assertTrue(classConstraints.get(0).getLeft().equals("A"));
|
||||
assertTrue(classConstraints.get(0).getLeft().equals("A"));
|
||||
//assertTrue(classConstraints.get(0).getRight().equals("B"));
|
||||
}
|
||||
|
||||
@ -152,6 +152,16 @@ public class FamilyOfGeneratedGenericsTest extends TestCase {
|
||||
}
|
||||
|
||||
|
||||
public void testPositionConverter() {
|
||||
HashMap<String, Boolean> allTphsOld = new HashMap<>();
|
||||
allTphsOld.put("A", true);
|
||||
allTphsOld.put("B", false);
|
||||
HashMap<String, PositionFinder.Position> allTphsNew = FamilyOfGeneratedGenerics.positionConverter(allTphsOld);
|
||||
System.out.println(allTphsNew);
|
||||
|
||||
assertTrue(allTphsNew.get("A").equals(PositionFinder.Position.METHOD));
|
||||
assertTrue(allTphsNew.get("B").equals(PositionFinder.Position.FIELD));
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user