Ejemplo n.º 1
0
    private boolean compare(Object source, Object target, InternalWorkingMemory workingMemory) {
      BitSet sourceTraits = null;
      BitSet targetTraits = null;
      if (source instanceof Thing) {
        sourceTraits = ((TraitableBean) ((Thing) source).getCore()).getCurrentTypeCode();
      } else if (source instanceof TraitableBean) {
        sourceTraits = ((TraitableBean) source).getCurrentTypeCode();
      } else {
        TraitableBean tbean = lookForWrapper(source, workingMemory);
        if (tbean != null) {
          sourceTraits = tbean.getCurrentTypeCode();
        }
      }

      if (target instanceof Class) {
        CodedHierarchy x =
            ((ReteooRuleBase) workingMemory.getRuleBase())
                .getConfiguration()
                .getComponentFactory()
                .getTraitRegistry()
                .getHierarchy();
        targetTraits = x.getCode(((Class) target).getName());
      } else if (target instanceof String) {
        CodedHierarchy x =
            ((ReteooRuleBase) workingMemory.getRuleBase())
                .getConfiguration()
                .getComponentFactory()
                .getTraitRegistry()
                .getHierarchy();
        targetTraits = x.getCode(target);
      } else if (target instanceof Thing) {
        targetTraits = ((TraitableBean) ((Thing) target).getCore()).getCurrentTypeCode();
      } else if (target instanceof TraitableBean) {
        targetTraits = ((TraitableBean) target).getCurrentTypeCode();
      } else {
        TraitableBean tbean = lookForWrapper(target, workingMemory);
        if (tbean != null) {
          targetTraits = tbean.getCurrentTypeCode();
        }
      }

      if (sourceTraits == null || targetTraits == null) {
        return getOperator().isNegated();
      }

      return isA(sourceTraits, targetTraits) ^ getOperator().isNegated();
    }
Ejemplo n.º 2
0
 private void cacheLiteral(Object value, InternalWorkingMemory workingMemory) {
   CodedHierarchy x =
       ((ReteooRuleBase) workingMemory.getRuleBase())
           .getConfiguration()
           .getComponentFactory()
           .getTraitRegistry()
           .getHierarchy();
   cachedLiteral = getCode(value, x);
 }
Ejemplo n.º 3
0
 public static List<String> getSettableProperties(
     InternalWorkingMemory workingMemory, ObjectTypeNode objectTypeNode) {
   return getSettableProperties((InternalRuleBase) workingMemory.getRuleBase(), objectTypeNode);
 }