public PropagationContext adaptModificationMaskForObjectType(ObjectType type, InternalWorkingMemory workingMemory) {
if (isAllSetPropertyReactiveMask(originalMask) || originalMask.isSet(PropertySpecificUtil.TRAITABLE_BIT) || !(type instanceof ClassObjectType)) {
return this;
}
ClassObjectType classObjectType = (ClassObjectType)type;
BitMask cachedMask = classObjectType.getTransformedMask(modifiedClass, originalMask);
if (cachedMask != null) {
return this;
}
modificationMask = originalMask;
boolean typeBit = modificationMask.isSet(PropertySpecificUtil.TRAITABLE_BIT);
modificationMask = modificationMask.reset(PropertySpecificUtil.TRAITABLE_BIT);
Class<?> classType = classObjectType.getClassType();
String pkgName = classType.getPackage().getName();
if (classType == modifiedClass || "java.lang".equals(pkgName) || !(classType.isInterface() || modifiedClass.isInterface())) {
if (typeBit) {
modificationMask = modificationMask.set(PropertySpecificUtil.TRAITABLE_BIT);
}
return this;
}
List<String> typeClassProps = getSettableProperties(workingMemory, classType, pkgName);
List<String> modifiedClassProps = getSettableProperties( workingMemory, modifiedClass );
modificationMask = getEmptyPropertyReactiveMask(typeClassProps.size());
for (int i = 0; i < modifiedClassProps.size(); i++) {
if (isPropertySetOnMask(originalMask, i)) {
int posInType = typeClassProps.indexOf(modifiedClassProps.get(i));
if (posInType >= 0) {
modificationMask = setPropertyOnMask(modificationMask, posInType);
}
}
}
if (typeBit) {
modificationMask = modificationMask.set(PropertySpecificUtil.TRAITABLE_BIT);
}
classObjectType.storeTransformedMask(modifiedClass, originalMask, modificationMask);
return this;
}