packages/sql-semantics-sqlite/resources/models/Value/CmdWithCreatekwUniqueflagIndexIfnotexistsNmDbnmOnNmLpSortlistRpWhereOpt_0880662b.php

1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Statement\Model\Sqlite\Value;
6
7/**
8 * The cmd 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\Sqlite\Value\CmdWithCreatekwUniqueflagIndexIfnotexistsNmDbnmOnNmLpSortlistRpWhereOpt_0880662b $value): string => \SqlSemantics\Statement\Writer::render($value);
13 *     $write instanceof \Closure // => true
14 */
15final class CmdWithCreatekwUniqueflagIndexIfnotexistsNmDbnmOnNmLpSortlistRpWhereOpt_0880662b implements \SqlSemantics\Statement\Model\Sqlite\Role\CmdForm, \SqlSemantics\Statement\Model\Sqlite\Role\CmdxForm, \SqlSemantics\Statement\Command
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\Sqlite\Role\CreatekwForm $createkw,
24        public readonly \SqlSemantics\Statement\Model\Sqlite\Role\UniqueflagForm $uniqueflag,
25        public readonly \SqlSemantics\Statement\Model\Sqlite\Role\IfnotexistsForm $ifnotexists,
26        public readonly \SqlSemantics\Statement\Model\Sqlite\Role\NmForm $nm,
27        public readonly \SqlSemantics\Statement\Model\Sqlite\Role\DbnmForm $dbnm,
28        public readonly \SqlSemantics\Statement\Model\Sqlite\Role\NmForm $nm2,
29        public readonly \SqlSemantics\Statement\Model\Sqlite\Role\SortlistForm $sortlist,
30        public readonly \SqlSemantics\Statement\Model\Sqlite\Role\WhereOptForm $where,
31        public readonly \SqlSemantics\Statement\Comments $comments = new \SqlSemantics\Statement\Comments(),
32    ) {
33        $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($createkw), 'The createkw must be a generated immutable SQL value.');
34        $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($uniqueflag), 'The uniqueflag must be a generated immutable SQL value.');
35        $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($ifnotexists), 'The ifnotexists must be a generated immutable SQL value.');
36        $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($nm), 'The nm must be a generated immutable SQL value.');
37        $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($dbnm), 'The dbnm must be a generated immutable SQL value.');
38        $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($nm2), 'The nm2 must be a generated immutable SQL value.');
39        $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($sortlist), 'The sortlist must be a generated immutable SQL value.');
40        $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($where), 'The where must be a generated immutable SQL value.');
41    }
42
43    /**
44     * Writes SQL entirely from this value's fields.
45     */
46    public function write(\SqlSemantics\Statement\Writer $writer): void
47    {
48        $writer->comments($this->comments, 0);
49        $this->createkw->write($writer);
50        $writer->comments($this->comments, 1);
51        $this->uniqueflag->write($writer);
52        $writer->comments($this->comments, 2);
53        $writer->append('INDEX');
54        $writer->comments($this->comments, 3);
55        $this->ifnotexists->write($writer);
56        $writer->comments($this->comments, 4);
57        $this->nm->write($writer);
58        $writer->comments($this->comments, 5);
59        $this->dbnm->write($writer);
60        $writer->comments($this->comments, 6);
61        $writer->append('ON');
62        $writer->comments($this->comments, 7);
63        $this->nm2->write($writer);
64        $writer->comments($this->comments, 8);
65        $writer->append('(');
66        $writer->comments($this->comments, 9);
67        $this->sortlist->write($writer);
68        $writer->comments($this->comments, 10);
69        $writer->append(')');
70        $writer->comments($this->comments, 11);
71        $this->where->write($writer);
72    }
73
74    /**
75     * Returns a copy with a new createkw, preserving every other field.
76     */
77    public function withCreatekw(\SqlSemantics\Statement\Model\Sqlite\Role\CreatekwForm $createkw): self
78    {
79        return new self($createkw, $this->uniqueflag, $this->ifnotexists, $this->nm, $this->dbnm, $this->nm2, $this->sortlist, $this->where, $this->comments);
80    }
81
82    /**
83     * Returns a copy with a new uniqueflag, preserving every other field.
84     */
85    public function withUniqueflag(\SqlSemantics\Statement\Model\Sqlite\Role\UniqueflagForm $uniqueflag): self
86    {
87        return new self($this->createkw, $uniqueflag, $this->ifnotexists, $this->nm, $this->dbnm, $this->nm2, $this->sortlist, $this->where, $this->comments);
88    }
89
90    /**
91     * Returns a copy with a new ifnotexists, preserving every other field.
92     */
93    public function withIfnotexists(\SqlSemantics\Statement\Model\Sqlite\Role\IfnotexistsForm $ifnotexists): self
94    {
95        return new self($this->createkw, $this->uniqueflag, $ifnotexists, $this->nm, $this->dbnm, $this->nm2, $this->sortlist, $this->where, $this->comments);
96    }
97
98    /**
99     * Returns a copy with a new nm, preserving every other field.
100     */
101    public function withNm(\SqlSemantics\Statement\Model\Sqlite\Role\NmForm $nm): self
102    {
103        return new self($this->createkw, $this->uniqueflag, $this->ifnotexists, $nm, $this->dbnm, $this->nm2, $this->sortlist, $this->where, $this->comments);
104    }
105
106    /**
107     * Returns a copy with a new dbnm, preserving every other field.
108     */
109    public function withDbnm(\SqlSemantics\Statement\Model\Sqlite\Role\DbnmForm $dbnm): self
110    {
111        return new self($this->createkw, $this->uniqueflag, $this->ifnotexists, $this->nm, $dbnm, $this->nm2, $this->sortlist, $this->where, $this->comments);
112    }
113
114    /**
115     * Returns a copy with a new nm2, preserving every other field.
116     */
117    public function withNm2(\SqlSemantics\Statement\Model\Sqlite\Role\NmForm $nm2): self
118    {
119        return new self($this->createkw, $this->uniqueflag, $this->ifnotexists, $this->nm, $this->dbnm, $nm2, $this->sortlist, $this->where, $this->comments);
120    }
121
122    /**
123     * Returns a copy with a new sortlist, preserving every other field.
124     */
125    public function withSortlist(\SqlSemantics\Statement\Model\Sqlite\Role\SortlistForm $sortlist): self
126    {
127        return new self($this->createkw, $this->uniqueflag, $this->ifnotexists, $this->nm, $this->dbnm, $this->nm2, $sortlist, $this->where, $this->comments);
128    }
129
130    /**
131     * Returns a copy with a new where, preserving every other field.
132     */
133    public function withWhere(\SqlSemantics\Statement\Model\Sqlite\Role\WhereOptForm $where): self
134    {
135        return new self($this->createkw, $this->uniqueflag, $this->ifnotexists, $this->nm, $this->dbnm, $this->nm2, $this->sortlist, $where, $this->comments);
136    }
137
138    /**
139     * Returns a copy with a new comments, preserving every other field.
140     */
141    public function withComments(\SqlSemantics\Statement\Comments $comments): self
142    {
143        return new self($this->createkw, $this->uniqueflag, $this->ifnotexists, $this->nm, $this->dbnm, $this->nm2, $this->sortlist, $this->where, $comments);
144    }
145}
146