add transivity
This commit is contained in:
@@ -128,17 +128,48 @@ 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
|
@Override
|
||||||
public Set<PartType> getIncompatibilities(PartType reference) {
|
public Set<PartType> getIncompatibilities(PartType reference) {
|
||||||
// Il faut verifier ref est existé dans Hashmap
|
// Il faut verifier ref est existé dans Hashmap
|
||||||
//return this.incompatibilities.get(reference);
|
//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>());
|
return this.incompatibilities.getOrDefault(reference, new HashSet<PartType>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<PartType> getRequirements(PartType reference) {
|
public Set<PartType> getRequirements(PartType reference) {
|
||||||
//return this.requirements.get(reference);
|
Set<PartType> parts = this.requirements.getOrDefault(reference, new HashSet<PartType>());
|
||||||
return 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