public SelType binaryOps()

in netflix-sel/src/main/java/com/netflix/sel/type/SelLong.java [101:148]


  public SelType binaryOps(SelOp op, SelType rhs) {
    if (rhs.type() == SelTypes.NULL && (op == SelOp.EQUAL || op == SelOp.NOT_EQUAL)) {
      return rhs.binaryOps(op, this);
    }

    if (rhs.type() == SelTypes.DOUBLE) {
      SelDouble lhs = SelDouble.of(this.val);
      return lhs.binaryOps(op, rhs);
    }

    if (rhs.type() == SelTypes.STRING) {
      return SelString.of(String.valueOf(this.val)).binaryOps(op, rhs);
    }

    SelTypeUtil.checkTypeMatch(this.type(), rhs.type());
    long another = ((SelLong) rhs).val;
    switch (op) {
      case EQUAL:
        return SelBoolean.of(this.val == another);
      case NOT_EQUAL:
        return SelBoolean.of(this.val != another);
      case LT:
        return SelBoolean.of(this.val < another);
      case GT:
        return SelBoolean.of(this.val > another);
      case LTE:
        return SelBoolean.of(this.val <= another);
      case GTE:
        return SelBoolean.of(this.val >= another);
      case ADD:
        return new SelLong(this.val + another);
      case SUB:
        return new SelLong(this.val - another);
      case MUL:
        return new SelLong(this.val * another);
      case DIV:
        return new SelLong(this.val / another);
      case MOD:
        return new SelLong(this.val % another);
      case PLUS:
        return new SelLong(this.val);
      case MINUS:
        return new SelLong(-this.val);
      default:
        throw new UnsupportedOperationException(
            "int/Integer/long/Long DO NOT support expression operation " + op);
    }
  }