Skip to content

Commit

Permalink
Privatize KotlinFeature's enabledByDefault
Browse files Browse the repository at this point in the history
Suggested by efenderbosch@github & TWiStErRob@github
#477 (comment)
  • Loading branch information
dinomite committed Jul 20, 2021
1 parent 414327f commit 0793bbb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import kotlin.math.pow
/**
* @see KotlinModule.Builder
*/
enum class KotlinFeature(val enabledByDefault: Boolean) {
enum class KotlinFeature(private val enabledByDefault: Boolean) {
/**
* This feature represents whether to deserialize `null` values for collection properties as empty collections.
*/
Expand Down Expand Up @@ -45,4 +45,11 @@ enum class KotlinFeature(val enabledByDefault: Boolean) {
StrictNullChecks(enabledByDefault = false);

internal val bitSet: BitSet = 2.0.pow(ordinal).toInt().toBitSet()

companion object {
internal val defaults
get() = 0.toBitSet().apply {
values().filter { it.enabledByDefault }.forEach { or(it.bitSet) }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ class KotlinModule @Deprecated(
var reflectionCacheSize: Int = 512
private set

private val bitSet: BitSet = 0.toBitSet().apply {
KotlinFeature.values().filter { it.enabledByDefault }.forEach { or(it.bitSet) }
}
private val bitSet: BitSet = KotlinFeature.defaults

fun withReflectionCacheSize(reflectionCacheSize: Int): Builder = apply {
this.reflectionCacheSize = reflectionCacheSize
Expand Down

0 comments on commit 0793bbb

Please sign in to comment.