@Override
    public boolean eval(Map<String, Object> context) {
      String format = this.formatExdr.expandString(context);

      Object fieldVal = this.fieldAcsr.get(context);
      Object toFieldVal = this.toFieldAcsr.get(context);

      // always use an empty string by default
      if (fieldVal == null) {
        fieldVal = "";
      }

      List<Object> messages = FastList.newInstance();
      Boolean resultBool =
          BaseCompare.doRealCompare(
              fieldVal, toFieldVal, operator, type, format, messages, null, null, false);
      if (messages.size() > 0) {
        messages.add(
            0,
            "Error with comparison in if-compare-field between field ["
                + fieldAcsr.toString()
                + "] with value ["
                + fieldVal
                + "] and to-field ["
                + toFieldAcsr.toString()
                + "] with value ["
                + toFieldVal
                + "] with operator ["
                + operator
                + "] and type ["
                + type
                + "]: ");

        StringBuilder fullString = new StringBuilder();
        for (Object item : messages) {
          fullString.append(item.toString());
        }
        Debug.logWarning(fullString.toString(), module);

        throw new IllegalArgumentException(fullString.toString());
      }

      return resultBool.booleanValue();
    }
예제 #2
0
  public void doCompare(
      Object value1,
      Object value2,
      List<Object> messages,
      Locale locale,
      ClassLoader loader,
      boolean value2InlineConstant) {
    Boolean success =
        BaseCompare.doRealCompare(
            value1,
            value2,
            this.operator,
            this.type,
            this.format,
            messages,
            locale,
            loader,
            value2InlineConstant);

    if (success != null && success.booleanValue() == false) {
      addMessage(messages, loader, locale);
    }
  }