packages/sql-semantics-postgres/resources/models/Value/CreateTrigStmtWithCreateOptOrReplaceConstraintTriggerNameAfterTriggerEventsOnQualifiedNameOpt_0a3387e3.php
1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Statement\Model\PostgreSql\Value;
6
7/**
8 * The CreateTrigStmt 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\CreateTrigStmtWithCreateOptOrReplaceConstraintTriggerNameAfterTriggerEventsOnQualifiedNameOpt_0a3387e3 $value): string => \SqlSemantics\Statement\Writer::render($value);
13 * $write instanceof \Closure // => true
14 */
15final class CreateTrigStmtWithCreateOptOrReplaceConstraintTriggerNameAfterTriggerEventsOnQualifiedNameOpt_0a3387e3 implements \SqlSemantics\Statement\Model\PostgreSql\Role\CreateTrigStmtForm, \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\OptOrReplaceForm $optOrReplace,
24 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\NameForm $name,
25 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\TriggerEventsForm $triggerEvents,
26 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\QualifiedNameForm $qualifiedName,
27 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\OptConstrFromTableForm $optConstrFromTable,
28 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\ConstraintAttributeSpecForm $constraintAttributeSpec,
29 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\TriggerWhenForm $triggerWhen,
30 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\FunctionOrProcedureForm $functionOrProcedure,
31 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\FuncNameForm $funcName,
32 public readonly \SqlSemantics\Statement\Model\PostgreSql\Role\TriggerFuncArgsForm $triggerFuncArgs,
33 public readonly \SqlSemantics\Statement\Comments $comments = new \SqlSemantics\Statement\Comments(),
34 ) {
35 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($optOrReplace), 'The optOrReplace must be a generated immutable SQL value.');
36 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($name), 'The name must be a generated immutable SQL value.');
37 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($triggerEvents), 'The triggerEvents must be a generated immutable SQL value.');
38 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($qualifiedName), 'The qualifiedName must be a generated immutable SQL value.');
39 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($optConstrFromTable), 'The optConstrFromTable must be a generated immutable SQL value.');
40 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($constraintAttributeSpec), 'The constraintAttributeSpec must be a generated immutable SQL value.');
41 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($triggerWhen), 'The triggerWhen must be a generated immutable SQL value.');
42 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($functionOrProcedure), 'The functionOrProcedure must be a generated immutable SQL value.');
43 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($funcName), 'The funcName must be a generated immutable SQL value.');
44 $this->assert(\SqlSemantics\Statement\Model\PostgreSql\Contract\Contracts::contains($triggerFuncArgs), 'The triggerFuncArgs must be a generated immutable SQL value.');
45 }
46
47 /**
48 * Writes SQL entirely from this value's fields.
49 */
50 public function write(\SqlSemantics\Statement\Writer $writer): void
51 {
52 $writer->comments($this->comments, 0);
53 $writer->append('CREATE');
54 $writer->comments($this->comments, 1);
55 $this->optOrReplace->write($writer);
56 $writer->comments($this->comments, 2);
57 $writer->append('CONSTRAINT');
58 $writer->comments($this->comments, 3);
59 $writer->append('TRIGGER');
60 $writer->comments($this->comments, 4);
61 $this->name->write($writer);
62 $writer->comments($this->comments, 5);
63 $writer->append('AFTER');
64 $writer->comments($this->comments, 6);
65 $this->triggerEvents->write($writer);
66 $writer->comments($this->comments, 7);
67 $writer->append('ON');
68 $writer->comments($this->comments, 8);
69 $this->qualifiedName->write($writer);
70 $writer->comments($this->comments, 9);
71 $this->optConstrFromTable->write($writer);
72 $writer->comments($this->comments, 10);
73 $this->constraintAttributeSpec->write($writer);
74 $writer->comments($this->comments, 11);
75 $writer->append('FOR');
76 $writer->comments($this->comments, 12);
77 $writer->append('EACH');
78 $writer->comments($this->comments, 13);
79 $writer->append('ROW');
80 $writer->comments($this->comments, 14);
81 $this->triggerWhen->write($writer);
82 $writer->comments($this->comments, 15);
83 $writer->append('EXECUTE');
84 $writer->comments($this->comments, 16);
85 $this->functionOrProcedure->write($writer);
86 $writer->comments($this->comments, 17);
87 $this->funcName->write($writer);
88 $writer->comments($this->comments, 18);
89 $writer->append('(');
90 $writer->comments($this->comments, 19);
91 $this->triggerFuncArgs->write($writer);
92 $writer->comments($this->comments, 20);
93 $writer->append(')');
94 }
95
96 /**
97 * Returns a copy with a new optOrReplace, preserving every other field.
98 */
99 public function withOptOrReplace(\SqlSemantics\Statement\Model\PostgreSql\Role\OptOrReplaceForm $optOrReplace): self
100 {
101 return new self($optOrReplace, $this->name, $this->triggerEvents, $this->qualifiedName, $this->optConstrFromTable, $this->constraintAttributeSpec, $this->triggerWhen, $this->functionOrProcedure, $this->funcName, $this->triggerFuncArgs, $this->comments);
102 }
103
104 /**
105 * Returns a copy with a new name, preserving every other field.
106 */
107 public function withName(\SqlSemantics\Statement\Model\PostgreSql\Role\NameForm $name): self
108 {
109 return new self($this->optOrReplace, $name, $this->triggerEvents, $this->qualifiedName, $this->optConstrFromTable, $this->constraintAttributeSpec, $this->triggerWhen, $this->functionOrProcedure, $this->funcName, $this->triggerFuncArgs, $this->comments);
110 }
111
112 /**
113 * Returns a copy with a new triggerEvents, preserving every other field.
114 */
115 public function withTriggerEvents(\SqlSemantics\Statement\Model\PostgreSql\Role\TriggerEventsForm $triggerEvents): self
116 {
117 return new self($this->optOrReplace, $this->name, $triggerEvents, $this->qualifiedName, $this->optConstrFromTable, $this->constraintAttributeSpec, $this->triggerWhen, $this->functionOrProcedure, $this->funcName, $this->triggerFuncArgs, $this->comments);
118 }
119
120 /**
121 * Returns a copy with a new qualifiedName, preserving every other field.
122 */
123 public function withQualifiedName(\SqlSemantics\Statement\Model\PostgreSql\Role\QualifiedNameForm $qualifiedName): self
124 {
125 return new self($this->optOrReplace, $this->name, $this->triggerEvents, $qualifiedName, $this->optConstrFromTable, $this->constraintAttributeSpec, $this->triggerWhen, $this->functionOrProcedure, $this->funcName, $this->triggerFuncArgs, $this->comments);
126 }
127
128 /**
129 * Returns a copy with a new optConstrFromTable, preserving every other field.
130 */
131 public function withOptConstrFromTable(\SqlSemantics\Statement\Model\PostgreSql\Role\OptConstrFromTableForm $optConstrFromTable): self
132 {
133 return new self($this->optOrReplace, $this->name, $this->triggerEvents, $this->qualifiedName, $optConstrFromTable, $this->constraintAttributeSpec, $this->triggerWhen, $this->functionOrProcedure, $this->funcName, $this->triggerFuncArgs, $this->comments);
134 }
135
136 /**
137 * Returns a copy with a new constraintAttributeSpec, preserving every other field.
138 */
139 public function withConstraintAttributeSpec(\SqlSemantics\Statement\Model\PostgreSql\Role\ConstraintAttributeSpecForm $constraintAttributeSpec): self
140 {
141 return new self($this->optOrReplace, $this->name, $this->triggerEvents, $this->qualifiedName, $this->optConstrFromTable, $constraintAttributeSpec, $this->triggerWhen, $this->functionOrProcedure, $this->funcName, $this->triggerFuncArgs, $this->comments);
142 }
143
144 /**
145 * Returns a copy with a new triggerWhen, preserving every other field.
146 */
147 public function withTriggerWhen(\SqlSemantics\Statement\Model\PostgreSql\Role\TriggerWhenForm $triggerWhen): self
148 {
149 return new self($this->optOrReplace, $this->name, $this->triggerEvents, $this->qualifiedName, $this->optConstrFromTable, $this->constraintAttributeSpec, $triggerWhen, $this->functionOrProcedure, $this->funcName, $this->triggerFuncArgs, $this->comments);
150 }
151
152 /**
153 * Returns a copy with a new functionOrProcedure, preserving every other field.
154 */
155 public function withFunctionOrProcedure(\SqlSemantics\Statement\Model\PostgreSql\Role\FunctionOrProcedureForm $functionOrProcedure): self
156 {
157 return new self($this->optOrReplace, $this->name, $this->triggerEvents, $this->qualifiedName, $this->optConstrFromTable, $this->constraintAttributeSpec, $this->triggerWhen, $functionOrProcedure, $this->funcName, $this->triggerFuncArgs, $this->comments);
158 }
159
160 /**
161 * Returns a copy with a new funcName, preserving every other field.
162 */
163 public function withFuncName(\SqlSemantics\Statement\Model\PostgreSql\Role\FuncNameForm $funcName): self
164 {
165 return new self($this->optOrReplace, $this->name, $this->triggerEvents, $this->qualifiedName, $this->optConstrFromTable, $this->constraintAttributeSpec, $this->triggerWhen, $this->functionOrProcedure, $funcName, $this->triggerFuncArgs, $this->comments);
166 }
167
168 /**
169 * Returns a copy with a new triggerFuncArgs, preserving every other field.
170 */
171 public function withTriggerFuncArgs(\SqlSemantics\Statement\Model\PostgreSql\Role\TriggerFuncArgsForm $triggerFuncArgs): self
172 {
173 return new self($this->optOrReplace, $this->name, $this->triggerEvents, $this->qualifiedName, $this->optConstrFromTable, $this->constraintAttributeSpec, $this->triggerWhen, $this->functionOrProcedure, $this->funcName, $triggerFuncArgs, $this->comments);
174 }
175
176 /**
177 * Returns a copy with a new comments, preserving every other field.
178 */
179 public function withComments(\SqlSemantics\Statement\Comments $comments): self
180 {
181 return new self($this->optOrReplace, $this->name, $this->triggerEvents, $this->qualifiedName, $this->optConstrFromTable, $this->constraintAttributeSpec, $this->triggerWhen, $this->functionOrProcedure, $this->funcName, $this->triggerFuncArgs, $comments);
182 }
183}
184