@@ -10,6 +10,7 @@ import dm.sent.core.ExcludeMissing
1010import dm.sent.core.JsonField
1111import dm.sent.core.JsonMissing
1212import dm.sent.core.JsonValue
13+ import dm.sent.core.checkRequired
1314import dm.sent.errors.SentInvalidDataException
1415import java.util.Collections
1516import java.util.Objects
@@ -20,52 +21,44 @@ import kotlin.jvm.optionals.getOrNull
2021class SentDmServicesCommonContractsPocOsTemplateButton
2122@JsonCreator(mode = JsonCreator .Mode .DISABLED )
2223private constructor (
23- private val id: JsonField <Int >,
2424 private val props: JsonField <SentDmServicesCommonContractsPocOsTemplateButtonProps >,
2525 private val type: JsonField <String >,
26+ private val id: JsonField <Int >,
2627 private val additionalProperties: MutableMap <String , JsonValue >,
2728) {
2829
2930 @JsonCreator
3031 private constructor (
31- @JsonProperty(" id" ) @ExcludeMissing id: JsonField <Int > = JsonMissing .of(),
3232 @JsonProperty(" props" )
3333 @ExcludeMissing
3434 props: JsonField <SentDmServicesCommonContractsPocOsTemplateButtonProps > = JsonMissing .of(),
3535 @JsonProperty(" type" ) @ExcludeMissing type: JsonField <String > = JsonMissing .of(),
36- ) : this (id, props, type, mutableMapOf ())
37-
38- /* *
39- * The unique identifier of the button (1-based index)
40- *
41- * @throws SentInvalidDataException if the JSON field has an unexpected type (e.g. if the server
42- * responded with an unexpected value).
43- */
44- fun id (): Optional <Int > = id.getOptional(" id" )
36+ @JsonProperty(" id" ) @ExcludeMissing id: JsonField <Int > = JsonMissing .of(),
37+ ) : this (props, type, id, mutableMapOf ())
4538
4639 /* *
4740 * Properties specific to the button type
4841 *
49- * @throws SentInvalidDataException if the JSON field has an unexpected type (e.g. if the server
50- * responded with an unexpected value).
42+ * @throws SentInvalidDataException if the JSON field has an unexpected type or is unexpectedly
43+ * missing or null (e.g. if the server responded with an unexpected value).
5144 */
52- fun props (): Optional <SentDmServicesCommonContractsPocOsTemplateButtonProps > =
53- props.getOptional(" props" )
45+ fun props (): SentDmServicesCommonContractsPocOsTemplateButtonProps = props.getRequired(" props" )
5446
5547 /* *
5648 * The type of button (e.g., QUICK_REPLY, URL, PHONE_NUMBER, VOICE_CALL, COPY_CODE)
5749 *
58- * @throws SentInvalidDataException if the JSON field has an unexpected type (e.g. if the server
59- * responded with an unexpected value).
50+ * @throws SentInvalidDataException if the JSON field has an unexpected type or is unexpectedly
51+ * missing or null (e.g. if the server responded with an unexpected value).
6052 */
61- fun type (): Optional < String > = type.getOptional (" type" )
53+ fun type (): String = type.getRequired (" type" )
6254
6355 /* *
64- * Returns the raw JSON value of [id].
56+ * The unique identifier of the button (1-based index)
6557 *
66- * Unlike [id], this method doesn't throw if the JSON field has an unexpected type.
58+ * @throws SentInvalidDataException if the JSON field has an unexpected type (e.g. if the server
59+ * responded with an unexpected value).
6760 */
68- @JsonProperty( " id " ) @ExcludeMissing fun _id (): JsonField <Int > = id
61+ fun id (): Optional <Int > = id.getOptional( " id " )
6962
7063 /* *
7164 * Returns the raw JSON value of [props].
@@ -83,6 +76,13 @@ private constructor(
8376 */
8477 @JsonProperty(" type" ) @ExcludeMissing fun _type (): JsonField <String > = type
8578
79+ /* *
80+ * Returns the raw JSON value of [id].
81+ *
82+ * Unlike [id], this method doesn't throw if the JSON field has an unexpected type.
83+ */
84+ @JsonProperty(" id" ) @ExcludeMissing fun _id (): JsonField <Int > = id
85+
8686 @JsonAnySetter
8787 private fun putAdditionalProperty (key : String , value : JsonValue ) {
8888 additionalProperties.put(key, value)
@@ -100,42 +100,36 @@ private constructor(
100100 /* *
101101 * Returns a mutable builder for constructing an instance of
102102 * [SentDmServicesCommonContractsPocOsTemplateButton].
103+ *
104+ * The following fields are required:
105+ * ```java
106+ * .props()
107+ * .type()
108+ * ```
103109 */
104110 @JvmStatic fun builder () = Builder ()
105111 }
106112
107113 /* * A builder for [SentDmServicesCommonContractsPocOsTemplateButton]. */
108114 class Builder internal constructor() {
109115
116+ private var props: JsonField <SentDmServicesCommonContractsPocOsTemplateButtonProps >? = null
117+ private var type: JsonField <String >? = null
110118 private var id: JsonField <Int > = JsonMissing .of()
111- private var props: JsonField <SentDmServicesCommonContractsPocOsTemplateButtonProps > =
112- JsonMissing .of()
113- private var type: JsonField <String > = JsonMissing .of()
114119 private var additionalProperties: MutableMap <String , JsonValue > = mutableMapOf ()
115120
116121 @JvmSynthetic
117122 internal fun from (
118123 sentDmServicesCommonContractsPocOsTemplateButton :
119124 SentDmServicesCommonContractsPocOsTemplateButton
120125 ) = apply {
121- id = sentDmServicesCommonContractsPocOsTemplateButton.id
122126 props = sentDmServicesCommonContractsPocOsTemplateButton.props
123127 type = sentDmServicesCommonContractsPocOsTemplateButton.type
128+ id = sentDmServicesCommonContractsPocOsTemplateButton.id
124129 additionalProperties =
125130 sentDmServicesCommonContractsPocOsTemplateButton.additionalProperties.toMutableMap()
126131 }
127132
128- /* * The unique identifier of the button (1-based index) */
129- fun id (id : Int ) = id(JsonField .of(id))
130-
131- /* *
132- * Sets [Builder.id] to an arbitrary JSON value.
133- *
134- * You should usually call [Builder.id] with a well-typed [Int] value instead. This method
135- * is primarily for setting the field to an undocumented or not yet supported value.
136- */
137- fun id (id : JsonField <Int >) = apply { this .id = id }
138-
139133 /* * Properties specific to the button type */
140134 fun props (props : SentDmServicesCommonContractsPocOsTemplateButtonProps ) =
141135 props(JsonField .of(props))
@@ -162,6 +156,17 @@ private constructor(
162156 */
163157 fun type (type : JsonField <String >) = apply { this .type = type }
164158
159+ /* * The unique identifier of the button (1-based index) */
160+ fun id (id : Int ) = id(JsonField .of(id))
161+
162+ /* *
163+ * Sets [Builder.id] to an arbitrary JSON value.
164+ *
165+ * You should usually call [Builder.id] with a well-typed [Int] value instead. This method
166+ * is primarily for setting the field to an undocumented or not yet supported value.
167+ */
168+ fun id (id : JsonField <Int >) = apply { this .id = id }
169+
165170 fun additionalProperties (additionalProperties : Map <String , JsonValue >) = apply {
166171 this .additionalProperties.clear()
167172 putAllAdditionalProperties(additionalProperties)
@@ -185,12 +190,20 @@ private constructor(
185190 * Returns an immutable instance of [SentDmServicesCommonContractsPocOsTemplateButton].
186191 *
187192 * Further updates to this [Builder] will not mutate the returned instance.
193+ *
194+ * The following fields are required:
195+ * ```java
196+ * .props()
197+ * .type()
198+ * ```
199+ *
200+ * @throws IllegalStateException if any required field is unset.
188201 */
189202 fun build (): SentDmServicesCommonContractsPocOsTemplateButton =
190203 SentDmServicesCommonContractsPocOsTemplateButton (
204+ checkRequired(" props" , props),
205+ checkRequired(" type" , type),
191206 id,
192- props,
193- type,
194207 additionalProperties.toMutableMap(),
195208 )
196209 }
@@ -202,9 +215,9 @@ private constructor(
202215 return @apply
203216 }
204217
205- id()
206- props().ifPresent { it.validate() }
218+ props().validate()
207219 type()
220+ id()
208221 validated = true
209222 }
210223
@@ -223,26 +236,26 @@ private constructor(
223236 */
224237 @JvmSynthetic
225238 internal fun validity (): Int =
226- (if (id .asKnown().isPresent) 1 else 0 ) +
227- (props .asKnown().getOrNull()?.validity() ? : 0 ) +
228- (if (type .asKnown().isPresent) 1 else 0 )
239+ (props .asKnown().getOrNull()?.validity() ? : 0 ) +
240+ (if (type .asKnown().isPresent) 1 else 0 ) +
241+ (if (id .asKnown().isPresent) 1 else 0 )
229242
230243 override fun equals (other : Any? ): Boolean {
231244 if (this == = other) {
232245 return true
233246 }
234247
235248 return other is SentDmServicesCommonContractsPocOsTemplateButton &&
236- id == other.id &&
237249 props == other.props &&
238250 type == other.type &&
251+ id == other.id &&
239252 additionalProperties == other.additionalProperties
240253 }
241254
242- private val hashCode: Int by lazy { Objects .hash(id, props, type, additionalProperties) }
255+ private val hashCode: Int by lazy { Objects .hash(props, type, id , additionalProperties) }
243256
244257 override fun hashCode (): Int = hashCode
245258
246259 override fun toString () =
247- " SentDmServicesCommonContractsPocOsTemplateButton{id= $id , props=$props , type=$type , additionalProperties=$additionalProperties }"
260+ " SentDmServicesCommonContractsPocOsTemplateButton{props=$props , type=$type , id= $id , additionalProperties=$additionalProperties }"
248261}
0 commit comments