add transivity

This commit is contained in:
Minh VU
2024-10-24 08:33:28 +02:00
parent 8457ab48fa
commit 0b511522bc

View File

@@ -127,18 +127,49 @@ public class CompatibilityManagerImpl implements src.fr.api.CompatibilityManager
}
}
}
// A - incompatible B + B require C => A incompatbile C
// This is B require C
protected Set<PartType> getIncompability_middle(PartType reference){
return this.requirements.getOrDefault(reference, new HashSet<PartType>());
}
@Override
public Set<PartType> getIncompatibilities(PartType reference) {
// Il faut verifier ref est existé dans Hashmap
//return this.incompatibilities.get(reference);
//A incompatible B
Set<PartType> parts = this.incompatibilities.getOrDefault(reference, new HashSet<PartType>());
// A incompatible C
//Get all incomptability with transivity
if (parts != null){
for( PartType p: parts){
parts.addAll(this.getIncompability_middle(p));
}
}
return parts;
}
//Same but B incompatible C
protected Set<PartType> getRequirement_middle(PartType reference){
return this.incompatibilities.getOrDefault(reference, new HashSet<PartType>());
}
@Override
public Set<PartType> getRequirements(PartType reference) {
//return this.requirements.get(reference);
return this.requirements.getOrDefault(reference, new HashSet<PartType>());
Set<PartType> parts = this.requirements.getOrDefault(reference, new HashSet<PartType>());
// A incompatible C
//Get all incomptability with transivity
if (parts != null){
for( PartType p: parts){
parts.addAll(this.getRequirement_middle(p));
}
}
return parts;
}
}