示例#1
0
  @Override
  protected void initDeclaredMask(BuildContext context, LeftTupleSource leftInput) {
    if (context == null || context.getLastBuiltPatterns() == null) {
      // only happens during unit tests
      rightDeclaredMask = Long.MAX_VALUE;
      super.initDeclaredMask(context, leftInput);
      return;
    }

    if (!(rightInput instanceof RightInputAdapterNode)) {
      Pattern pattern = context.getLastBuiltPatterns()[0]; // right input pattern
      ObjectType objectType = pattern.getObjectType();

      if (!(objectType instanceof ClassObjectType)) {
        // InitialFact has no type declaration and cannot be property specific
        // Only ClassObjectType can use property specific
        rightDeclaredMask = Long.MAX_VALUE;
      }

      Class objectClass = ((ClassObjectType) objectType).getClassType();
      if (isPropertyReactive(context, objectClass)) {
        rightListenedProperties = pattern.getListenedProperties();
        List<String> settableProperties = getSettableProperties(context.getRuleBase(), objectClass);
        rightDeclaredMask = calculatePositiveMask(rightListenedProperties, settableProperties);
        rightDeclaredMask |= constraints.getListenedPropertyMask(settableProperties);
        rightNegativeMask = calculateNegativeMask(rightListenedProperties, settableProperties);
      } else {
        // if property reactive is not on, then accept all modification propagations
        rightDeclaredMask = Long.MAX_VALUE;
      }
    } else {
      rightDeclaredMask = Long.MAX_VALUE;
      // There would have been no right input pattern, so swap current to first, so leftInput can
      // still work
      context.setLastBuiltPattern(context.getLastBuiltPatterns()[0]);
    }

    super.initDeclaredMask(context, leftInput);
  }