packages/sql-semantics-mysql/resources/models/Value/PredicateWithBitExprNotInSymExprExprList_2feb440c.php

1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Statement\Model\MySql\Value;
6
7/**
8 * The predicate SQL value; generated by bin/build-models.php.
9 *
10 * @visibility public
11 * @example Accept a structured SQL value
12 *     $write = static fn (\SqlSemantics\Statement\Model\MySql\Value\PredicateWithBitExprNotInSymExprExprList_2feb440c $value): string => \SqlSemantics\Statement\Writer::render($value);
13 *     $write instanceof \Closure // => true
14 */
15final class PredicateWithBitExprNotInSymExprExprList_2feb440c implements \SqlSemantics\Statement\Model\MySql\Role\BoolPriForm, \SqlSemantics\Statement\Model\MySql\Role\ExprForm, \SqlSemantics\Statement\Model\MySql\Role\ExprListForm, \SqlSemantics\Statement\Model\MySql\Role\ExprOrDefaultForm, \SqlSemantics\Statement\Model\MySql\Role\GeneratedColumnFuncForm, \SqlSemantics\Statement\Model\MySql\Role\GroupListForm, \SqlSemantics\Statement\Model\MySql\Role\GroupingExprForm, \SqlSemantics\Statement\Model\MySql\Role\InstallSetRvalueForm, \SqlSemantics\Statement\Model\MySql\Role\OptExprForm, \SqlSemantics\Statement\Model\MySql\Role\OptExprListForm, \SqlSemantics\Statement\Model\MySql\Role\OptSpCparamsForm, \SqlSemantics\Statement\Model\MySql\Role\OptValuesForm, \SqlSemantics\Statement\Model\MySql\Role\OrderIdentForm, \SqlSemantics\Statement\Model\MySql\Role\PredicateForm, \SqlSemantics\Statement\Model\MySql\Role\SetExprOrDefaultForm, \SqlSemantics\Statement\Model\MySql\Role\SpCparamsForm, \SqlSemantics\Statement\Model\MySql\Role\ValuesForm
16{
17    use \SqlSemantics\Statement\Assertion;
18
19    /**
20     * Supplies the SQL values of this form; comments are kept by the position of the symbol each precedes.
21     */
22    public function __construct(
23        public readonly \SqlSemantics\Statement\Model\MySql\Role\BitExprForm $bitExpr,
24        public readonly \SqlSemantics\Statement\Model\MySql\Role\NotForm $not,
25        public readonly \SqlSemantics\Statement\Model\MySql\Role\ExprForm $expr,
26        public readonly \SqlSemantics\Statement\Model\MySql\Role\ExprListForm $exprList,
27        public readonly \SqlSemantics\Statement\Comments $comments = new \SqlSemantics\Statement\Comments(),
28    ) {
29        $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($bitExpr), 'The bitExpr must be a generated immutable SQL value.');
30        $this->assertOperandBindingStrength($bitExpr, \SqlSemantics\Statement\Model\MySql\Contract\Contracts::BINDING_POWERS, array (  'mysql-8.0.44' => 27,  'mysql-8.1.0' => 27,  'mysql-8.2.0' => 27,  'mysql-8.3.0' => 27,  'mysql-8.4.7' => 27,  'mysql-9.0.1' => 27,  'mysql-9.1.0' => 27,));
31        $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($not), 'The not must be a generated immutable SQL value.');
32        $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($expr), 'The expr must be a generated immutable SQL value.');
33        $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($exprList), 'The exprList must be a generated immutable SQL value.');
34    }
35
36    /**
37     * Writes SQL entirely from this value's fields.
38     */
39    public function write(\SqlSemantics\Statement\Writer $writer): void
40    {
41        $writer->comments($this->comments, 0);
42        $this->bitExpr->write($writer);
43        $writer->comments($this->comments, 1);
44        $this->not->write($writer);
45        $writer->comments($this->comments, 2);
46        $writer->append('IN');
47        $writer->comments($this->comments, 3);
48        $writer->append('(');
49        $writer->comments($this->comments, 4);
50        $this->expr->write($writer);
51        $writer->comments($this->comments, 5);
52        $writer->append(',');
53        $writer->comments($this->comments, 6);
54        $this->exprList->write($writer);
55        $writer->comments($this->comments, 7);
56        $writer->append(')');
57    }
58
59    /**
60     * Returns a copy with a new bitExpr, preserving every other field.
61     */
62    public function withBitExpr(\SqlSemantics\Statement\Model\MySql\Role\BitExprForm $bitExpr): self
63    {
64        return new self($bitExpr, $this->not, $this->expr, $this->exprList, $this->comments);
65    }
66
67    /**
68     * Returns a copy with a new not, preserving every other field.
69     */
70    public function withNot(\SqlSemantics\Statement\Model\MySql\Role\NotForm $not): self
71    {
72        return new self($this->bitExpr, $not, $this->expr, $this->exprList, $this->comments);
73    }
74
75    /**
76     * Returns a copy with a new expr, preserving every other field.
77     */
78    public function withExpr(\SqlSemantics\Statement\Model\MySql\Role\ExprForm $expr): self
79    {
80        return new self($this->bitExpr, $this->not, $expr, $this->exprList, $this->comments);
81    }
82
83    /**
84     * Returns a copy with a new exprList, preserving every other field.
85     */
86    public function withExprList(\SqlSemantics\Statement\Model\MySql\Role\ExprListForm $exprList): self
87    {
88        return new self($this->bitExpr, $this->not, $this->expr, $exprList, $this->comments);
89    }
90
91    /**
92     * Returns a copy with a new comments, preserving every other field.
93     */
94    public function withComments(\SqlSemantics\Statement\Comments $comments): self
95    {
96        return new self($this->bitExpr, $this->not, $this->expr, $this->exprList, $comments);
97    }
98}
99