public static Object compare(Object obj1, Object obj2, int compOp) throws TypeMismatchException {
    // Check for nulls first.
    if (obj1 == null || obj2 == null) {
      Boolean result = nullCompare(obj1, obj2, compOp);

      if (result == null) {
        return QueryService.UNDEFINED;
      }

      return result;
    }

    // if either object is UNDEFINED, result is UNDEFINED
    if (obj1 == QueryService.UNDEFINED || obj2 == QueryService.UNDEFINED) {
      if (compOp == TOK_NE && !(obj1 == QueryService.UNDEFINED && obj2 == QueryService.UNDEFINED)) {
        return true;
      } else if (compOp == TOK_EQ && obj1.equals(obj2)) {
        return true;
      } else {
        return QueryService.UNDEFINED;
      }
    }

    // Prepare pdx instances if needed.
    if (obj1 instanceof PdxInstanceEnumInfo && obj2 instanceof Enum) {
      obj2 = new PdxInstanceEnum((Enum<?>) obj2);
    } else if (obj1 instanceof Enum && obj2 instanceof PdxInstanceEnumInfo) {
      obj1 = new PdxInstanceEnum((Enum<?>) obj1);
    }

    if (obj1 instanceof PdxString && obj2 instanceof String) {
      obj2 = new PdxString((String) obj2);
    } else if (obj1 instanceof String && obj2 instanceof PdxString) {
      obj1 = new PdxString((String) obj1);
    }

    try {
      ComparisonStrategy strategy =
          ComparisonStrategy.get(obj1.getClass(), obj2.getClass(), compOp);
      return strategy.execute(obj1, obj2, compOp);
    } catch (ClassCastException | TypeMismatchException e) {
      // if a ClassCastException or TypeMismatchException was thrown and the operator is equals
      // or not equals, then override and return true or false.
      if (compOp == TOK_EQ) {
        return Boolean.FALSE;
      }

      if (compOp == TOK_NE) {
        return Boolean.TRUE;
      }

      if (isAssignableFrom(e.getClass(), ClassCastException.class)) {
        throw new TypeMismatchException(
            String.format("Unable to compare object of type ' %s ' with object of type ' %s '",

                obj1.getClass().getName(), obj2.getClass().getName()),
            e);
      } else {
        throw e;
      }
    }
  }
Compares two objects using the operator

@return boolean;<br>
        {@link Undefined} if either of the operands is {@link Undefined} or if either of the
        operands is Null and operator is other than == or !=
geode-core/src/main/java/org/apache/geode/cache/query/internal/types/TypeUtils.java