use of org.drools.core.factmodel.traits.TraitType in project drools by kiegroup.
the class TraitObjectTypeNode method sameAndNotCoveredByDescendants.
/**
* Edge case: due to the way traits are encoded, consider this hierarchy:
* A B
* C
* D
* On don/insertion of C, C may be vetoed by its parents, but might have been
* already covered by one of its descendants (D)
*/
private boolean sameAndNotCoveredByDescendants(TraitProxy proxy, BitSet typeMask) {
boolean isSameType = typeMask.equals(proxy._getTypeCode());
if (isSameType) {
TraitTypeMap<String, Thing<?>, ?> ttm = (TraitTypeMap<String, Thing<?>, ?>) proxy.getObject()._getTraitMap();
Collection<Thing<?>> descs = ttm.lowerDescendants(typeMask);
// we have to exclude the "mock" bottom proxy
if (descs == null || descs.isEmpty()) {
return true;
} else {
for (Thing sub : descs) {
TraitType tt = (TraitType) sub;
if (tt != proxy && tt._hasTypeCode(typeMask)) {
return false;
}
}
return true;
}
} else {
return false;
}
}
Aggregations