add transivity
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user