packages/sql-semantics-sqlite/resources/models/Value/TriggerDeclWithTempTriggerIfnotexistsNmDbnmTriggerTimeTriggerEventOnFullnameForeachClauseW_09bb7d8c.php
1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Statement\Model\Sqlite\Value;
6
7/**
8 * The trigger_decl 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\TriggerDeclWithTempTriggerIfnotexistsNmDbnmTriggerTimeTriggerEventOnFullnameForeachClauseW_09bb7d8c $value): string => \SqlSemantics\Statement\Writer::render($value);
13 * $write instanceof \Closure // => true
14 */
15final class TriggerDeclWithTempTriggerIfnotexistsNmDbnmTriggerTimeTriggerEventOnFullnameForeachClauseW_09bb7d8c implements \SqlSemantics\Statement\Model\Sqlite\Role\TriggerDeclForm
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\TempForm $temp,
24 public readonly \SqlSemantics\Statement\Model\Sqlite\Role\IfnotexistsForm $ifnotexists,
25 public readonly \SqlSemantics\Statement\Model\Sqlite\Role\NmForm $nm,
26 public readonly \SqlSemantics\Statement\Model\Sqlite\Role\DbnmForm $dbnm,
27 public readonly \SqlSemantics\Statement\Model\Sqlite\Role\TriggerTimeForm $triggerTime,
28 public readonly \SqlSemantics\Statement\Model\Sqlite\Role\TriggerEventForm $triggerEvent,
29 public readonly \SqlSemantics\Statement\Model\Sqlite\Role\FullnameForm $fullname,
30 public readonly \SqlSemantics\Statement\Model\Sqlite\Role\ForeachClauseForm $foreachClause,
31 public readonly \SqlSemantics\Statement\Model\Sqlite\Role\WhenClauseForm $whenClause,
32 public readonly \SqlSemantics\Statement\Comments $comments = new \SqlSemantics\Statement\Comments(),
33 ) {
34 $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($temp), 'The temp 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($triggerTime), 'The triggerTime must be a generated immutable SQL value.');
39 $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($triggerEvent), 'The triggerEvent must be a generated immutable SQL value.');
40 $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($fullname), 'The fullname must be a generated immutable SQL value.');
41 $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($foreachClause), 'The foreachClause must be a generated immutable SQL value.');
42 $this->assert(\SqlSemantics\Statement\Model\Sqlite\Contract\Contracts::contains($whenClause), 'The whenClause must be a generated immutable SQL value.');
43 }
44
45 /**
46 * Writes SQL entirely from this value's fields.
47 */
48 public function write(\SqlSemantics\Statement\Writer $writer): void
49 {
50 $writer->comments($this->comments, 0);
51 $this->temp->write($writer);
52 $writer->comments($this->comments, 1);
53 $writer->append('TRIGGER');
54 $writer->comments($this->comments, 2);
55 $this->ifnotexists->write($writer);
56 $writer->comments($this->comments, 3);
57 $this->nm->write($writer);
58 $writer->comments($this->comments, 4);
59 $this->dbnm->write($writer);
60 $writer->comments($this->comments, 5);
61 $this->triggerTime->write($writer);
62 $writer->comments($this->comments, 6);
63 $this->triggerEvent->write($writer);
64 $writer->comments($this->comments, 7);
65 $writer->append('ON');
66 $writer->comments($this->comments, 8);
67 $this->fullname->write($writer);
68 $writer->comments($this->comments, 9);
69 $this->foreachClause->write($writer);
70 $writer->comments($this->comments, 10);
71 $this->whenClause->write($writer);
72 }
73
74 /**
75 * Returns a copy with a new temp, preserving every other field.
76 */
77 public function withTemp(\SqlSemantics\Statement\Model\Sqlite\Role\TempForm $temp): self
78 {
79 return new self($temp, $this->ifnotexists, $this->nm, $this->dbnm, $this->triggerTime, $this->triggerEvent, $this->fullname, $this->foreachClause, $this->whenClause, $this->comments);
80 }
81
82 /**
83 * Returns a copy with a new ifnotexists, preserving every other field.
84 */
85 public function withIfnotexists(\SqlSemantics\Statement\Model\Sqlite\Role\IfnotexistsForm $ifnotexists): self
86 {
87 return new self($this->temp, $ifnotexists, $this->nm, $this->dbnm, $this->triggerTime, $this->triggerEvent, $this->fullname, $this->foreachClause, $this->whenClause, $this->comments);
88 }
89
90 /**
91 * Returns a copy with a new nm, preserving every other field.
92 */
93 public function withNm(\SqlSemantics\Statement\Model\Sqlite\Role\NmForm $nm): self
94 {
95 return new self($this->temp, $this->ifnotexists, $nm, $this->dbnm, $this->triggerTime, $this->triggerEvent, $this->fullname, $this->foreachClause, $this->whenClause, $this->comments);
96 }
97
98 /**
99 * Returns a copy with a new dbnm, preserving every other field.
100 */
101 public function withDbnm(\SqlSemantics\Statement\Model\Sqlite\Role\DbnmForm $dbnm): self
102 {
103 return new self($this->temp, $this->ifnotexists, $this->nm, $dbnm, $this->triggerTime, $this->triggerEvent, $this->fullname, $this->foreachClause, $this->whenClause, $this->comments);
104 }
105
106 /**
107 * Returns a copy with a new triggerTime, preserving every other field.
108 */
109 public function withTriggerTime(\SqlSemantics\Statement\Model\Sqlite\Role\TriggerTimeForm $triggerTime): self
110 {
111 return new self($this->temp, $this->ifnotexists, $this->nm, $this->dbnm, $triggerTime, $this->triggerEvent, $this->fullname, $this->foreachClause, $this->whenClause, $this->comments);
112 }
113
114 /**
115 * Returns a copy with a new triggerEvent, preserving every other field.
116 */
117 public function withTriggerEvent(\SqlSemantics\Statement\Model\Sqlite\Role\TriggerEventForm $triggerEvent): self
118 {
119 return new self($this->temp, $this->ifnotexists, $this->nm, $this->dbnm, $this->triggerTime, $triggerEvent, $this->fullname, $this->foreachClause, $this->whenClause, $this->comments);
120 }
121
122 /**
123 * Returns a copy with a new fullname, preserving every other field.
124 */
125 public function withFullname(\SqlSemantics\Statement\Model\Sqlite\Role\FullnameForm $fullname): self
126 {
127 return new self($this->temp, $this->ifnotexists, $this->nm, $this->dbnm, $this->triggerTime, $this->triggerEvent, $fullname, $this->foreachClause, $this->whenClause, $this->comments);
128 }
129
130 /**
131 * Returns a copy with a new foreachClause, preserving every other field.
132 */
133 public function withForeachClause(\SqlSemantics\Statement\Model\Sqlite\Role\ForeachClauseForm $foreachClause): self
134 {
135 return new self($this->temp, $this->ifnotexists, $this->nm, $this->dbnm, $this->triggerTime, $this->triggerEvent, $this->fullname, $foreachClause, $this->whenClause, $this->comments);
136 }
137
138 /**
139 * Returns a copy with a new whenClause, preserving every other field.
140 */
141 public function withWhenClause(\SqlSemantics\Statement\Model\Sqlite\Role\WhenClauseForm $whenClause): self
142 {
143 return new self($this->temp, $this->ifnotexists, $this->nm, $this->dbnm, $this->triggerTime, $this->triggerEvent, $this->fullname, $this->foreachClause, $whenClause, $this->comments);
144 }
145
146 /**
147 * Returns a copy with a new comments, preserving every other field.
148 */
149 public function withComments(\SqlSemantics\Statement\Comments $comments): self
150 {
151 return new self($this->temp, $this->ifnotexists, $this->nm, $this->dbnm, $this->triggerTime, $this->triggerEvent, $this->fullname, $this->foreachClause, $this->whenClause, $comments);
152 }
153}
154