packages/sql-semantics-mysql/resources/models/Value/WindowFuncCallWithNthValueSymExprSimpleExprOptFromFirstLastOptNullTreatmentWindowingClause_5a83eb1e.php
1<?php
2
3declare(strict_types=1);
4
5namespace SqlSemantics\Statement\Model\MySql\Value;
6
7/**
8 * The window_func_call 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\WindowFuncCallWithNthValueSymExprSimpleExprOptFromFirstLastOptNullTreatmentWindowingClause_5a83eb1e $value): string => \SqlSemantics\Statement\Writer::render($value);
13 * $write instanceof \Closure // => true
14 */
15final class WindowFuncCallWithNthValueSymExprSimpleExprOptFromFirstLastOptNullTreatmentWindowingClause_5a83eb1e implements \SqlSemantics\Statement\Model\MySql\Role\BitExprForm, \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\PartFuncExprForm, \SqlSemantics\Statement\Model\MySql\Role\PartFuncMaxForm, \SqlSemantics\Statement\Model\MySql\Role\PartValueExprItemForm, \SqlSemantics\Statement\Model\MySql\Role\PartValueItemForm, \SqlSemantics\Statement\Model\MySql\Role\PartValueItemListForm, \SqlSemantics\Statement\Model\MySql\Role\PartValueListForm, \SqlSemantics\Statement\Model\MySql\Role\PartValuesInForm, \SqlSemantics\Statement\Model\MySql\Role\PredicateForm, \SqlSemantics\Statement\Model\MySql\Role\SetExprOrDefaultForm, \SqlSemantics\Statement\Model\MySql\Role\SimpleExprForm, \SqlSemantics\Statement\Model\MySql\Role\SpCparamsForm, \SqlSemantics\Statement\Model\MySql\Role\ValuesForm, \SqlSemantics\Statement\Model\MySql\Role\WindowFuncCallForm
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\ExprForm $expr,
24 public readonly \SqlSemantics\Statement\Model\MySql\Role\SimpleExprForm $simpleExpr,
25 public readonly \SqlSemantics\Statement\Model\MySql\Role\OptFromFirstLastForm $optFromFirstLast,
26 public readonly \SqlSemantics\Statement\Model\MySql\Role\OptNullTreatmentForm $optNullTreatment,
27 public readonly \SqlSemantics\Statement\Model\MySql\Role\WindowingClauseForm $windowingClause,
28 public readonly \SqlSemantics\Statement\Comments $comments = new \SqlSemantics\Statement\Comments(),
29 ) {
30 $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($expr), 'The expr must be a generated immutable SQL value.');
31 $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($simpleExpr), 'The simpleExpr must be a generated immutable SQL value.');
32 $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($optFromFirstLast), 'The optFromFirstLast must be a generated immutable SQL value.');
33 $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($optNullTreatment), 'The optNullTreatment must be a generated immutable SQL value.');
34 $this->assert(\SqlSemantics\Statement\Model\MySql\Contract\Contracts::contains($windowingClause), 'The windowingClause must be a generated immutable SQL value.');
35 }
36
37 /**
38 * Writes SQL entirely from this value's fields.
39 */
40 public function write(\SqlSemantics\Statement\Writer $writer): void
41 {
42 $writer->comments($this->comments, 0);
43 $writer->append('NTH_VALUE');
44 $writer->comments($this->comments, 1);
45 $writer->append('(');
46 $writer->comments($this->comments, 2);
47 $this->expr->write($writer);
48 $writer->comments($this->comments, 3);
49 $writer->append(',');
50 $writer->comments($this->comments, 4);
51 $this->simpleExpr->write($writer);
52 $writer->comments($this->comments, 5);
53 $writer->append(')');
54 $writer->comments($this->comments, 6);
55 $this->optFromFirstLast->write($writer);
56 $writer->comments($this->comments, 7);
57 $this->optNullTreatment->write($writer);
58 $writer->comments($this->comments, 8);
59 $this->windowingClause->write($writer);
60 }
61
62 /**
63 * Returns a copy with a new expr, preserving every other field.
64 */
65 public function withExpr(\SqlSemantics\Statement\Model\MySql\Role\ExprForm $expr): self
66 {
67 return new self($expr, $this->simpleExpr, $this->optFromFirstLast, $this->optNullTreatment, $this->windowingClause, $this->comments);
68 }
69
70 /**
71 * Returns a copy with a new simpleExpr, preserving every other field.
72 */
73 public function withSimpleExpr(\SqlSemantics\Statement\Model\MySql\Role\SimpleExprForm $simpleExpr): self
74 {
75 return new self($this->expr, $simpleExpr, $this->optFromFirstLast, $this->optNullTreatment, $this->windowingClause, $this->comments);
76 }
77
78 /**
79 * Returns a copy with a new optFromFirstLast, preserving every other field.
80 */
81 public function withOptFromFirstLast(\SqlSemantics\Statement\Model\MySql\Role\OptFromFirstLastForm $optFromFirstLast): self
82 {
83 return new self($this->expr, $this->simpleExpr, $optFromFirstLast, $this->optNullTreatment, $this->windowingClause, $this->comments);
84 }
85
86 /**
87 * Returns a copy with a new optNullTreatment, preserving every other field.
88 */
89 public function withOptNullTreatment(\SqlSemantics\Statement\Model\MySql\Role\OptNullTreatmentForm $optNullTreatment): self
90 {
91 return new self($this->expr, $this->simpleExpr, $this->optFromFirstLast, $optNullTreatment, $this->windowingClause, $this->comments);
92 }
93
94 /**
95 * Returns a copy with a new windowingClause, preserving every other field.
96 */
97 public function withWindowingClause(\SqlSemantics\Statement\Model\MySql\Role\WindowingClauseForm $windowingClause): self
98 {
99 return new self($this->expr, $this->simpleExpr, $this->optFromFirstLast, $this->optNullTreatment, $windowingClause, $this->comments);
100 }
101
102 /**
103 * Returns a copy with a new comments, preserving every other field.
104 */
105 public function withComments(\SqlSemantics\Statement\Comments $comments): self
106 {
107 return new self($this->expr, $this->simpleExpr, $this->optFromFirstLast, $this->optNullTreatment, $this->windowingClause, $comments);
108 }
109}
110