Skip to content

Commit

Permalink
Remove cache process
Browse files Browse the repository at this point in the history
  • Loading branch information
kciter committed Jul 6, 2023
1 parent d8d6873 commit eb4d1bf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ subprojects {
apply(plugin = "signing")

group = "so.kciter"
version = "0.0.7"
version = "0.0.8"

tasks {
compileKotlin {
Expand Down Expand Up @@ -109,7 +109,7 @@ subprojects {
email.set("[email protected]")
url.set("https://github.com/sallyjellyy")
}

contributor {
name.set("roach")
email.set("[email protected]")
Expand Down
11 changes: 11 additions & 0 deletions thing/src/main/kotlin/so/kciter/thing/Rule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ class Rule<T>(
) {
companion object {
operator fun <T> invoke(init: RuleBuilder<T>.() -> Unit): Rule<T> {
// return if (RuleCache.rules.containsKey(this::class)) {
// @Suppress("UNCHECKED_CAST")
// RuleCache.rules[this::class] as Rule<T>
// } else {
// val builder = RuleBuilder<T>()
// val rule = builder.apply(init).build()
// RuleCache.rules[this::class] = rule
//
// rule
// }

val builder = RuleBuilder<T>()
return builder.apply(init).build()
}
Expand Down
21 changes: 6 additions & 15 deletions thing/src/main/kotlin/so/kciter/thing/RuleBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,10 @@ open class RuleBuilder<T> {
redactionRules.add(redaction)
}

fun build(): Rule<T> {
return if (RuleCache.rules.containsKey(this::class)) {
@Suppress("UNCHECKED_CAST")
RuleCache.rules[this::class] as Rule<T>
} else {
val rule = Rule(
validationRules = validationRules,
normalizationRules = normalizationRules,
redactionRules = redactionRules
)
RuleCache.rules[this::class] = rule

rule
}
}
fun build(): Rule<T> =
Rule(
validationRules = validationRules,
normalizationRules = normalizationRules,
redactionRules = redactionRules
)
}

0 comments on commit eb4d1bf

Please sign in to comment.