packages/sql-semantics-postgres/resources/models/Value/IndexStmtWithCreateOptUniqueIndexOptConcurrentlyIfPNotExistsNameOnRelationExprAccessMeth_6a1d0de6.php
1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Statement\Model\PostgreSql\Value;
6
7/**
8 * The IndexStmt 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\PostgreSql\Value\IndexStmtWithCreateOptUniqueIndexOptConcurrentlyIfPNotExistsNameOnRelationExprAccessMeth_6a1d0de6 $value): string => \SqlSemantics\Statement\Writer::render($value);
13 * $write instanceof \Closure // => true
14 */
15final class IndexStmtWithCreateOptUniqueIndexOptConcurrentlyIfPNotExistsNameOnRelationExprAccessMeth_6a1d0de6 implements \SqlSemantics\Statement\Model\PostgreSql\Role\IndexStmtForm, \SqlSemantics\Statement\Model\PostgreSql\Role\ParseToplevelForm, \SqlSemantics\Statement\Model\PostgreSql\Role\RoutineBodyStmtForm, \SqlSemantics\Statement\Model\PostgreSql\Role\SchemaStmtForm, \SqlSemantics\Statement\Model\PostgreSql\Role\StmtForm, \SqlSemantics\Statement\Model\PostgreSql\Role\StmtmultiForm, \SqlSemantics\Statement\Model\PostgreSql\Role\ToplevelStmtForm, \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\PostgreSql\Role\OptUniqueForm $optUnique,
24 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\OptConcurrentlyForm $optConcurrently,
25 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\NameForm $name,
26 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\RelationExprForm $relationExpr,
27 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\AccessMethodClauseForm $accessMethodClause,
28 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\IndexParamsForm $indexParams,
29 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\OptIncludeForm $optInclude,
30 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\OptUniqueNullTreatmentForm $optUniqueNullTreatment,
31 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\OptReloptionsForm $optReloptions,
32 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\OptTableSpaceForm $optTableSpace,
33 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\WhereClauseForm $where,
34 public readonly \SqlSemantics\Statement\Comments $comments = new \SqlSemantics\Statement\Comments(),
35 ) {
36 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($optUnique), 'The optUnique must be a generated immutable SQL value.');
37 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($optConcurrently), 'The optConcurrently must be a generated immutable SQL value.');
38 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($name), 'The name must be a generated immutable SQL value.');
39 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($relationExpr), 'The relationExpr must be a generated immutable SQL value.');
40 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($accessMethodClause), 'The accessMethodClause must be a generated immutable SQL value.');
41 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($indexParams), 'The indexParams must be a generated immutable SQL value.');
42 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($optInclude), 'The optInclude must be a generated immutable SQL value.');
43 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($optUniqueNullTreatment), 'The optUniqueNullTreatment must be a generated immutable SQL value.');
44 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($optReloptions), 'The optReloptions must be a generated immutable SQL value.');
45 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($optTableSpace), 'The optTableSpace must be a generated immutable SQL value.');
46 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($where), 'The where must be a generated immutable SQL value.');
47 }
48
49 /**
50 * Writes SQL entirely from this value's fields.
51 */
52 public function write(\SqlSemantics\Statement\Writer $writer): void
53 {
54 $writer->comments($this->comments, 0);
55 $writer->append('CREATE');
56 $writer->comments($this->comments, 1);
57 $this->optUnique->write($writer);
58 $writer->comments($this->comments, 2);
59 $writer->append('INDEX');
60 $writer->comments($this->comments, 3);
61 $this->optConcurrently->write($writer);
62 $writer->comments($this->comments, 4);
63 $writer->append('IF');
64 $writer->comments($this->comments, 5);
65 $writer->append('NOT');
66 $writer->comments($this->comments, 6);
67 $writer->append('EXISTS');
68 $writer->comments($this->comments, 7);
69 $this->name->write($writer);
70 $writer->comments($this->comments, 8);
71 $writer->append('ON');
72 $writer->comments($this->comments, 9);
73 $this->relationExpr->write($writer);
74 $writer->comments($this->comments, 10);
75 $this->accessMethodClause->write($writer);
76 $writer->comments($this->comments, 11);
77 $writer->append('(');
78 $writer->comments($this->comments, 12);
79 $this->indexParams->write($writer);
80 $writer->comments($this->comments, 13);
81 $writer->append(')');
82 $writer->comments($this->comments, 14);
83 $this->optInclude->write($writer);
84 $writer->comments($this->comments, 15);
85 $this->optUniqueNullTreatment->write($writer);
86 $writer->comments($this->comments, 16);
87 $this->optReloptions->write($writer);
88 $writer->comments($this->comments, 17);
89 $this->optTableSpace->write($writer);
90 $writer->comments($this->comments, 18);
91 $this->where->write($writer);
92 }
93
94 /**
95 * Returns a copy with a new optUnique, preserving every other field.
96 */
97 public function withOptUnique(\SqlSemantics\Statement\Model\PostgreSql\Role\OptUniqueForm $optUnique): self
98 {
99 return new self($optUnique, $this->optConcurrently, $this->name, $this->relationExpr, $this->accessMethodClause, $this->indexParams, $this->optInclude, $this->optUniqueNullTreatment, $this->optReloptions, $this->optTableSpace, $this->where, $this->comments);
100 }
101
102 /**
103 * Returns a copy with a new optConcurrently, preserving every other field.
104 */
105 public function withOptConcurrently(\SqlSemantics\Statement\Model\PostgreSql\Role\OptConcurrentlyForm $optConcurrently): self
106 {
107 return new self($this->optUnique, $optConcurrently, $this->name, $this->relationExpr, $this->accessMethodClause, $this->indexParams, $this->optInclude, $this->optUniqueNullTreatment, $this->optReloptions, $this->optTableSpace, $this->where, $this->comments);
108 }
109
110 /**
111 * Returns a copy with a new name, preserving every other field.
112 */
113 public function withName(\SqlSemantics\Statement\Model\PostgreSql\Role\NameForm $name): self
114 {
115 return new self($this->optUnique, $this->optConcurrently, $name, $this->relationExpr, $this->accessMethodClause, $this->indexParams, $this->optInclude, $this->optUniqueNullTreatment, $this->optReloptions, $this->optTableSpace, $this->where, $this->comments);
116 }
117
118 /**
119 * Returns a copy with a new relationExpr, preserving every other field.
120 */
121 public function withRelationExpr(\SqlSemantics\Statement\Model\PostgreSql\Role\RelationExprForm $relationExpr): self
122 {
123 return new self($this->optUnique, $this->optConcurrently, $this->name, $relationExpr, $this->accessMethodClause, $this->indexParams, $this->optInclude, $this->optUniqueNullTreatment, $this->optReloptions, $this->optTableSpace, $this->where, $this->comments);
124 }
125
126 /**
127 * Returns a copy with a new accessMethodClause, preserving every other field.
128 */
129 public function withAccessMethodClause(\SqlSemantics\Statement\Model\PostgreSql\Role\AccessMethodClauseForm $accessMethodClause): self
130 {
131 return new self($this->optUnique, $this->optConcurrently, $this->name, $this->relationExpr, $accessMethodClause, $this->indexParams, $this->optInclude, $this->optUniqueNullTreatment, $this->optReloptions, $this->optTableSpace, $this->where, $this->comments);
132 }
133
134 /**
135 * Returns a copy with a new indexParams, preserving every other field.
136 */
137 public function withIndexParams(\SqlSemantics\Statement\Model\PostgreSql\Role\IndexParamsForm $indexParams): self
138 {
139 return new self($this->optUnique, $this->optConcurrently, $this->name, $this->relationExpr, $this->accessMethodClause, $indexParams, $this->optInclude, $this->optUniqueNullTreatment, $this->optReloptions, $this->optTableSpace, $this->where, $this->comments);
140 }
141
142 /**
143 * Returns a copy with a new optInclude, preserving every other field.
144 */
145 public function withOptInclude(\SqlSemantics\Statement\Model\PostgreSql\Role\OptIncludeForm $optInclude): self
146 {
147 return new self($this->optUnique, $this->optConcurrently, $this->name, $this->relationExpr, $this->accessMethodClause, $this->indexParams, $optInclude, $this->optUniqueNullTreatment, $this->optReloptions, $this->optTableSpace, $this->where, $this->comments);
148 }
149
150 /**
151 * Returns a copy with a new optUniqueNullTreatment, preserving every other field.
152 */
153 public function withOptUniqueNullTreatment(\SqlSemantics\Statement\Model\PostgreSql\Role\OptUniqueNullTreatmentForm $optUniqueNullTreatment): self
154 {
155 return new self($this->optUnique, $this->optConcurrently, $this->name, $this->relationExpr, $this->accessMethodClause, $this->indexParams, $this->optInclude, $optUniqueNullTreatment, $this->optReloptions, $this->optTableSpace, $this->where, $this->comments);
156 }
157
158 /**
159 * Returns a copy with a new optReloptions, preserving every other field.
160 */
161 public function withOptReloptions(\SqlSemantics\Statement\Model\PostgreSql\Role\OptReloptionsForm $optReloptions): self
162 {
163 return new self($this->optUnique, $this->optConcurrently, $this->name, $this->relationExpr, $this->accessMethodClause, $this->indexParams, $this->optInclude, $this->optUniqueNullTreatment, $optReloptions, $this->optTableSpace, $this->where, $this->comments);
164 }
165
166 /**
167 * Returns a copy with a new optTableSpace, preserving every other field.
168 */
169 public function withOptTableSpace(\SqlSemantics\Statement\Model\PostgreSql\Role\OptTableSpaceForm $optTableSpace): self
170 {
171 return new self($this->optUnique, $this->optConcurrently, $this->name, $this->relationExpr, $this->accessMethodClause, $this->indexParams, $this->optInclude, $this->optUniqueNullTreatment, $this->optReloptions, $optTableSpace, $this->where, $this->comments);
172 }
173
174 /**
175 * Returns a copy with a new where, preserving every other field.
176 */
177 public function withWhere(\SqlSemantics\Statement\Model\PostgreSql\Role\WhereClauseForm $where): self
178 {
179 return new self($this->optUnique, $this->optConcurrently, $this->name, $this->relationExpr, $this->accessMethodClause, $this->indexParams, $this->optInclude, $this->optUniqueNullTreatment, $this->optReloptions, $this->optTableSpace, $where, $this->comments);
180 }
181
182 /**
183 * Returns a copy with a new comments, preserving every other field.
184 */
185 public function withComments(\SqlSemantics\Statement\Comments $comments): self
186 {
187 return new self($this->optUnique, $this->optConcurrently, $this->name, $this->relationExpr, $this->accessMethodClause, $this->indexParams, $this->optInclude, $this->optUniqueNullTreatment, $this->optReloptions, $this->optTableSpace, $this->where, $comments);
188 }
189}
190