Search in sources :

Example 1 with TraitType

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;
    }
}
Also used : TraitType(org.drools.core.factmodel.traits.TraitType) TraitTypeMap(org.drools.core.factmodel.traits.TraitTypeMap) Thing(org.drools.core.factmodel.traits.Thing)

Aggregations

Thing (org.drools.core.factmodel.traits.Thing)1 TraitType (org.drools.core.factmodel.traits.TraitType)1 TraitTypeMap (org.drools.core.factmodel.traits.TraitTypeMap)1