22
33package com.tryfinch.api.models
44
5- import com.fasterxml.jackson.annotation.JsonAnyGetter
6- import com.fasterxml.jackson.annotation.JsonAnySetter
7- import com.fasterxml.jackson.annotation.JsonCreator
8- import com.fasterxml.jackson.annotation.JsonProperty
9- import com.tryfinch.api.core.ExcludeMissing
10- import com.tryfinch.api.core.JsonField
11- import com.tryfinch.api.core.JsonMissing
12- import com.tryfinch.api.core.JsonValue
13- import com.tryfinch.api.errors.FinchInvalidDataException
145import com.tryfinch.api.services.async.hris.benefits.IndividualServiceAsync
15- import java.util.Collections
166import java.util.Objects
177import java.util.Optional
188import java.util.concurrent.CompletableFuture
199import java.util.concurrent.Executor
2010import java.util.function.Predicate
21- import kotlin.jvm.optionals.getOrNull
2211
2312/* * Get enrollment information for the given individuals. */
2413class HrisBenefitIndividualRetrieveManyBenefitsPageAsync
2514private constructor (
2615 private val individualsService: IndividualServiceAsync ,
2716 private val params: HrisBenefitIndividualRetrieveManyBenefitsParams ,
28- private val response : Response ,
17+ private val items : List < IndividualBenefit > ,
2918) {
3019
31- fun response (): Response = response
32-
33- fun items (): List <IndividualBenefit > = response().items()
20+ /* * Returns the response that this page was parsed from. */
21+ fun items (): List <IndividualBenefit > = items
3422
3523 override fun equals (other : Any? ): Boolean {
3624 if (this == = other) {
3725 return true
3826 }
3927
40- return /* spotless:off */ other is HrisBenefitIndividualRetrieveManyBenefitsPageAsync && individualsService == other.individualsService && params == other.params && response == other.response /* spotless:on */
28+ return /* spotless:off */ other is HrisBenefitIndividualRetrieveManyBenefitsPageAsync && individualsService == other.individualsService && params == other.params && items == other.items /* spotless:on */
4129 }
4230
43- override fun hashCode (): Int = /* spotless:off */ Objects .hash(individualsService, params, response ) /* spotless:on */
31+ override fun hashCode (): Int = /* spotless:off */ Objects .hash(individualsService, params, items ) /* spotless:on */
4432
4533 override fun toString () =
46- " HrisBenefitIndividualRetrieveManyBenefitsPageAsync{individualsService=$individualsService , params=$params , response= $response }"
34+ " HrisBenefitIndividualRetrieveManyBenefitsPageAsync{individualsService=$individualsService , params=$params , items= $items }"
4735
48- fun hasNextPage (): Boolean {
49- return ! items().isEmpty()
50- }
36+ fun hasNextPage (): Boolean = items.isNotEmpty()
5137
52- fun getNextPageParams (): Optional <HrisBenefitIndividualRetrieveManyBenefitsParams > {
53- return Optional .empty()
54- }
38+ fun getNextPageParams (): Optional <HrisBenefitIndividualRetrieveManyBenefitsParams > =
39+ Optional .empty()
5540
5641 fun getNextPage ():
5742 CompletableFuture <Optional <HrisBenefitIndividualRetrieveManyBenefitsPageAsync >> {
@@ -68,104 +53,8 @@ private constructor(
6853 fun of (
6954 individualsService : IndividualServiceAsync ,
7055 params : HrisBenefitIndividualRetrieveManyBenefitsParams ,
71- response : Response ,
72- ) = HrisBenefitIndividualRetrieveManyBenefitsPageAsync (individualsService, params, response)
73- }
74-
75- class Response (
76- private val items : JsonField <List <IndividualBenefit >>,
77- private val additionalProperties : MutableMap <String , JsonValue >,
78- ) {
79-
80- @JsonCreator
81- private constructor (
82- @JsonProperty(" items" ) items: JsonField <List <IndividualBenefit >> = JsonMissing .of()
83- ) : this (items, mutableMapOf ())
84-
85- fun items (): List <IndividualBenefit > = items.getOptional(" items" ).getOrNull() ? : listOf ()
86-
87- @JsonProperty(" items" )
88- fun _items (): Optional <JsonField <List <IndividualBenefit >>> = Optional .ofNullable(items)
89-
90- @JsonAnySetter
91- private fun putAdditionalProperty (key : String , value : JsonValue ) {
92- additionalProperties.put(key, value)
93- }
94-
95- @JsonAnyGetter
96- @ExcludeMissing
97- fun _additionalProperties (): Map <String , JsonValue > =
98- Collections .unmodifiableMap(additionalProperties)
99-
100- private var validated: Boolean = false
101-
102- fun validate (): Response = apply {
103- if (validated) {
104- return @apply
105- }
106-
107- items().map { it.validate() }
108- validated = true
109- }
110-
111- fun isValid (): Boolean =
112- try {
113- validate()
114- true
115- } catch (e: FinchInvalidDataException ) {
116- false
117- }
118-
119- fun toBuilder () = Builder ().from(this )
120-
121- override fun equals (other : Any? ): Boolean {
122- if (this == = other) {
123- return true
124- }
125-
126- return /* spotless:off */ other is Response && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */
127- }
128-
129- override fun hashCode (): Int = /* spotless:off */ Objects .hash(items, additionalProperties) /* spotless:on */
130-
131- override fun toString () =
132- " Response{items=$items , additionalProperties=$additionalProperties }"
133-
134- companion object {
135-
136- /* *
137- * Returns a mutable builder for constructing an instance of
138- * [HrisBenefitIndividualRetrieveManyBenefitsPageAsync].
139- */
140- @JvmStatic fun builder () = Builder ()
141- }
142-
143- class Builder {
144-
145- private var items: JsonField <List <IndividualBenefit >> = JsonMissing .of()
146- private var additionalProperties: MutableMap <String , JsonValue > = mutableMapOf ()
147-
148- @JvmSynthetic
149- internal fun from (page : Response ) = apply {
150- this .items = page.items
151- this .additionalProperties.putAll(page.additionalProperties)
152- }
153-
154- fun items (items : List <IndividualBenefit >) = items(JsonField .of(items))
155-
156- fun items (items : JsonField <List <IndividualBenefit >>) = apply { this .items = items }
157-
158- fun putAdditionalProperty (key : String , value : JsonValue ) = apply {
159- this .additionalProperties.put(key, value)
160- }
161-
162- /* *
163- * Returns an immutable instance of [Response].
164- *
165- * Further updates to this [Builder] will not mutate the returned instance.
166- */
167- fun build (): Response = Response (items, additionalProperties.toMutableMap())
168- }
56+ items : List <IndividualBenefit >,
57+ ) = HrisBenefitIndividualRetrieveManyBenefitsPageAsync (individualsService, params, items)
16958 }
17059
17160 class AutoPager (private val firstPage : HrisBenefitIndividualRetrieveManyBenefitsPageAsync ) {
0 commit comments