public static boolean isPropertyReactive(BuildContext context, Class<?> objectClass) { TypeDeclaration typeDeclaration = context.getRuleBase().getTypeDeclaration( objectClass ); return typeDeclaration != null && typeDeclaration.isPropertyReactive(); }
public static List<String> getSettableProperties(InternalRuleBase ruleBase, Class<?> nodeClass) { if (nodeClass == null) { return null; } TypeDeclaration typeDeclaration = ruleBase.getTypeDeclaration(nodeClass); if (typeDeclaration == null) { return ClassUtils.getSettableProperties(nodeClass); } typeDeclaration.setTypeClass(nodeClass); return typeDeclaration.getSettableProperties(); }
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;
public void initDeclaredMask(BuildContext context) { if ( context == null || context.getLastBuiltPatterns() == null ) { // only happens during unit tests declaredMask = -1L; return; } Pattern pattern = context.getLastBuiltPatterns()[0]; ObjectType objectType = pattern.getObjectType(); if ( !(objectType instanceof ClassObjectType)) { // Only ClassObjectType can use property specific declaredMask = -1L; return; } Class objectClass = ((ClassObjectType)objectType).getClassType(); TypeDeclaration typeDeclaration = context.getRuleBase().getTypeDeclaration(objectClass); if ( typeDeclaration == null || !typeDeclaration.isPropertyReactive() ) { // if property specific is not on, then accept all modification propagations declaredMask = -1L; } else { List<String> settableProperties = getSettableProperties(context.getRuleBase(), objectClass); declaredMask = calculateDeclaredMask(settableProperties); } }
this.ruleBase = ruleBase; this.entryPoint = entryPoint; this.typeDecl = ruleBase.getTypeDeclaration( clazz ); isEvent = typeDecl != null && typeDecl.getRole() == TypeDeclaration.Role.EVENT;
public void initDeclaredMask(BuildContext context) { if ( !(unwrapTupleSource() instanceof LeftInputAdapterNode)) { // RTN's not after LIANode are not relevant for property specific, so don't block anything. setDeclaredMask( -1L ); return; } Pattern pattern = context.getLastBuiltPatterns()[0]; ObjectType objectType = pattern.getObjectType(); if ( !(objectType instanceof ClassObjectType) ) { // InitialFact has no type declaration and cannot be property specific // Only ClassObjectType can use property specific setDeclaredMask( -1L ); return; } Class objectClass = ((ClassObjectType)objectType).getClassType(); TypeDeclaration typeDeclaration = context.getRuleBase().getTypeDeclaration(objectClass); if ( typeDeclaration == null || !typeDeclaration.isPropertyReactive() ) { // if property specific is not on, then accept all modification propagations setDeclaredMask( -1L ); } else { List<String> settableProperties = getSettableProperties(context.getRuleBase(), objectClass); setDeclaredMask( calculatePositiveMask(pattern.getListenedProperties(), settableProperties) ); setNegativeMask( calculateNegativeMask(pattern.getListenedProperties(), settableProperties) ); } }