Skip to content

Commit 4923608

Browse files
committed
Add explicit return values to Builder methods
1 parent 5b1c85d commit 4923608

File tree

1 file changed

+39
-28
lines changed

1 file changed

+39
-28
lines changed

src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinModule.kt

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -129,32 +129,33 @@ class KotlinModule @Deprecated(level = DeprecationLevel.WARNING, message = "Use
129129
KotlinFeature.values().filter { it.enabledByDefault }.forEach { or(it.bitSet) }
130130
}
131131

132-
fun withReflectionCacheSize(reflectionCacheSize: Int) = apply {
132+
fun withReflectionCacheSize(reflectionCacheSize: Int): Builder = apply {
133133
this.reflectionCacheSize = reflectionCacheSize
134134
}
135135

136-
fun enable(feature: KotlinFeature) = apply {
136+
fun enable(feature: KotlinFeature): Builder = apply {
137137
bitSet.or(feature.bitSet)
138138
}
139139

140-
fun disable(feature: KotlinFeature) = apply {
140+
fun disable(feature: KotlinFeature): Builder = apply {
141141
bitSet.andNot(feature.bitSet)
142142
}
143143

144-
fun configure(feature: KotlinFeature, enabled: Boolean) = when {
145-
enabled -> enable(feature)
146-
else -> disable(feature)
147-
}
144+
fun configure(feature: KotlinFeature, enabled: Boolean): Builder =
145+
when {
146+
enabled -> enable(feature)
147+
else -> disable(feature)
148+
}
148149

149-
fun isEnabled(feature: KotlinFeature): Boolean = bitSet.intersects(feature.bitSet)
150+
fun isEnabled(feature: KotlinFeature): Boolean =
151+
bitSet.intersects(feature.bitSet)
150152

151153
@Deprecated(
152154
message = "Deprecated, use withReflectionCacheSize(reflectionCacheSize) instead.",
153155
replaceWith = ReplaceWith("withReflectionCacheSize(reflectionCacheSize)")
154156
)
155-
fun reflectionCacheSize(reflectionCacheSize: Int) = apply {
156-
this.reflectionCacheSize = reflectionCacheSize
157-
}
157+
fun reflectionCacheSize(reflectionCacheSize: Int): Builder =
158+
withReflectionCacheSize(reflectionCacheSize)
158159

159160
@Deprecated(
160161
message = "Deprecated, use isEnabled(NullToEmptyCollection) instead.",
@@ -163,7 +164,8 @@ class KotlinModule @Deprecated(level = DeprecationLevel.WARNING, message = "Use
163164
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
164165
)
165166
)
166-
fun getNullToEmptyCollection() = isEnabled(NullToEmptyCollection)
167+
fun getNullToEmptyCollection(): Boolean =
168+
isEnabled(NullToEmptyCollection)
167169

168170
@Deprecated(
169171
message = "Deprecated, use configure(NullToEmptyCollection, enabled) instead.",
@@ -172,7 +174,7 @@ class KotlinModule @Deprecated(level = DeprecationLevel.WARNING, message = "Use
172174
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
173175
)
174176
)
175-
fun nullToEmptyCollection(nullToEmptyCollection: Boolean) =
177+
fun nullToEmptyCollection(nullToEmptyCollection: Boolean): Builder =
176178
configure(NullToEmptyCollection, nullToEmptyCollection)
177179

178180
@Deprecated(
@@ -182,7 +184,8 @@ class KotlinModule @Deprecated(level = DeprecationLevel.WARNING, message = "Use
182184
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
183185
)
184186
)
185-
fun getNullToEmptyMap() = isEnabled(NullToEmptyMap)
187+
fun getNullToEmptyMap(): Boolean =
188+
isEnabled(NullToEmptyMap)
186189

187190
@Deprecated(
188191
message = "Deprecated, use configure(NullToEmptyMap, enabled) instead.",
@@ -191,7 +194,8 @@ class KotlinModule @Deprecated(level = DeprecationLevel.WARNING, message = "Use
191194
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
192195
)
193196
)
194-
fun nullToEmptyMap(nullToEmptyMap: Boolean) = configure(NullToEmptyMap, nullToEmptyMap)
197+
fun nullToEmptyMap(nullToEmptyMap: Boolean): Builder =
198+
configure(NullToEmptyMap, nullToEmptyMap)
195199

196200
@Deprecated(
197201
message = "Deprecated, use isEnabled(NullIsSameAsDefault) instead.",
@@ -200,7 +204,8 @@ class KotlinModule @Deprecated(level = DeprecationLevel.WARNING, message = "Use
200204
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
201205
)
202206
)
203-
fun getNullIsSameAsDefault() = isEnabled(NullIsSameAsDefault)
207+
fun getNullIsSameAsDefault(): Boolean =
208+
isEnabled(NullIsSameAsDefault)
204209

205210
@Deprecated(
206211
message = "Deprecated, use configure(NullIsSameAsDefault, enabled) instead.",
@@ -209,7 +214,8 @@ class KotlinModule @Deprecated(level = DeprecationLevel.WARNING, message = "Use
209214
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
210215
)
211216
)
212-
fun nullIsSameAsDefault(nullIsSameAsDefault: Boolean) = configure(NullIsSameAsDefault, nullIsSameAsDefault)
217+
fun nullIsSameAsDefault(nullIsSameAsDefault: Boolean): Builder =
218+
configure(NullIsSameAsDefault, nullIsSameAsDefault)
213219

214220
@Deprecated(
215221
message = "Deprecated, use isEnabled(SingletonSupport) instead.",
@@ -218,10 +224,11 @@ class KotlinModule @Deprecated(level = DeprecationLevel.WARNING, message = "Use
218224
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
219225
)
220226
)
221-
fun getSingletonSupport() = when {
222-
isEnabled(KotlinFeature.SingletonSupport) -> CANONICALIZE
223-
else -> DISABLED
224-
}
227+
fun getSingletonSupport(): SingletonSupport =
228+
when {
229+
isEnabled(KotlinFeature.SingletonSupport) -> CANONICALIZE
230+
else -> DISABLED
231+
}
225232

226233
@Deprecated(
227234
message = "Deprecated, use configure(SingletonSupport, enabled) instead.",
@@ -230,10 +237,11 @@ class KotlinModule @Deprecated(level = DeprecationLevel.WARNING, message = "Use
230237
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
231238
)
232239
)
233-
fun singletonSupport(singletonSupport: SingletonSupport) = when (singletonSupport) {
234-
CANONICALIZE -> enable(KotlinFeature.SingletonSupport)
235-
else -> disable(KotlinFeature.SingletonSupport)
236-
}
240+
fun singletonSupport(singletonSupport: SingletonSupport): Builder =
241+
when (singletonSupport) {
242+
CANONICALIZE -> enable(KotlinFeature.SingletonSupport)
243+
else -> disable(KotlinFeature.SingletonSupport)
244+
}
237245

238246
@Deprecated(
239247
message = "Deprecated, use isEnabled(StrictNullChecks) instead.",
@@ -242,7 +250,8 @@ class KotlinModule @Deprecated(level = DeprecationLevel.WARNING, message = "Use
242250
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
243251
)
244252
)
245-
fun getStrictNullChecks() = isEnabled(StrictNullChecks)
253+
fun getStrictNullChecks(): Boolean =
254+
isEnabled(StrictNullChecks)
246255

247256
@Deprecated(
248257
message = "Deprecated, use configure(StrictNullChecks, enabled) instead.",
@@ -251,8 +260,10 @@ class KotlinModule @Deprecated(level = DeprecationLevel.WARNING, message = "Use
251260
"com.fasterxml.jackson.module.kotlin.KotlinFeature"
252261
)
253262
)
254-
fun strictNullChecks(strictNullChecks: Boolean) = configure(StrictNullChecks, strictNullChecks)
263+
fun strictNullChecks(strictNullChecks: Boolean): Builder =
264+
configure(StrictNullChecks, strictNullChecks)
255265

256-
fun build() = KotlinModule(this)
266+
fun build(): KotlinModule =
267+
KotlinModule(this)
257268
}
258269
}

0 commit comments

Comments
 (0)