コード例 #1
0
    public boolean evaluate(
        InternalWorkingMemory workingMemory,
        InternalReadAccessor leftExtractor,
        InternalFactHandle left,
        InternalReadAccessor rightExtractor,
        InternalFactHandle right) {
      final Object value1 = leftExtractor.getValue(workingMemory, left);
      final Object value2 = rightExtractor.getValue(workingMemory, right);

      Object target = value1;
      Object source = value2;

      return compare(source, target, workingMemory);
    }
コード例 #2
0
    /** @inheridDoc */
    public boolean evaluate(
        InternalWorkingMemory workingMemory,
        InternalReadAccessor extractor,
        InternalFactHandle handle,
        FieldValue value) {
      final Object objectValue = extractor.getValue(workingMemory, handle.getObject());
      final Object literal = value.getValue();
      if (cachedValue != literal) {
        cachedValue = literal;
        cacheLiteral(literal, workingMemory);
      }

      TraitableBean core;
      if (objectValue instanceof Thing) {
        Thing thing = (Thing) objectValue;
        core = (TraitableBean) thing.getCore();
        BitSet code = core.getCurrentTypeCode();
        if (code != null) {
          return this.getOperator().isNegated() ^ isA(code, cachedLiteral);
        } else {
          return this.getOperator().isNegated() ^ hasTrait(core, literal);
        }
      } else if (objectValue instanceof TraitableBean) {
        core = (TraitableBean) objectValue;
        BitSet code = core.getCurrentTypeCode();
        if (code != null) {
          return this.getOperator().isNegated() ^ isA(code, cachedLiteral);
        } else {
          return this.getOperator().isNegated() ^ hasTrait(core, literal);
        }
      } else {
        core = lookForWrapper(objectValue, workingMemory);
        if (core == null) {
          return this.getOperator().isNegated();
        }
        BitSet code = core.getCurrentTypeCode();
        if (code != null) {
          return this.getOperator().isNegated() ^ isA(code, cachedLiteral);
        } else {
          return this.getOperator().isNegated() ^ hasTrait(core, literal);
        }
      }
    }