}
private void calculateModificationMask(KnowledgeHelper knowledgeHelper, WithNode node) {
Class<?> nodeClass = node.getEgressType();
InternalRuleBase ruleBase = (InternalRuleBase)knowledgeHelper.getWorkingMemory().getRuleBase();
TypeDeclaration typeDeclaration = ruleBase.getTypeDeclaration(nodeClass);
if (typeDeclaration == null || !typeDeclaration.isPropertyReactive()) {
modificationMask = Long.MAX_VALUE;
return;
}
List<String> settableProperties = typeDeclaration.getSettableProperties();
modificationMask = 0L;
// TODO: access parmValuePairs without reflection
WithNode.ParmValuePair[] parmValuePairs = getFieldValue(WithNode.class, "withExpressions", node);
for (WithNode.ParmValuePair parmValuePair : parmValuePairs) {
Method method = extractMethod(parmValuePair);
if (method == null) {
modificationMask = Long.MAX_VALUE;
return;
}
String propertyName = setter2property(method.getName());
if (propertyName != null) {
int pos = settableProperties.indexOf(propertyName);
if (pos >= 0) modificationMask = BitMaskUtil.set(modificationMask, pos);
}
List<String> modifiedProps = typeDeclaration.getTypeClassDef().getModifiedPropsByMethod(method);
if (modifiedProps != null) {
for (String modifiedProp : modifiedProps) {
int pos = settableProperties.indexOf(modifiedProp);
if (pos >= 0) modificationMask = BitMaskUtil.set(modificationMask, pos);
}