Skip to content

Commit 3aeeedc

Browse files
committed
Remove hack delegates
1 parent 3b7c810 commit 3aeeedc

File tree

2 files changed

+2
-21
lines changed

2 files changed

+2
-21
lines changed

common/src/main/kotlin/com/lambda/config/Configurable.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ abstract class Configurable(
248248
* @param name The unique identifier for the setting.
249249
* @param defaultValue The default [Set] value of type [T] for the setting.
250250
* @param description A brief explanation of the setting's purpose and behavior.
251-
* @param hackDelegates A flag that determines whether the setting should be serialized with the default value.
252251
* @param visibility A lambda expression that determines the visibility status of the setting.
253252
*
254253
* ```kotlin
@@ -262,14 +261,12 @@ abstract class Configurable(
262261
name: String,
263262
defaultValue: Set<T>,
264263
description: String = "",
265-
hackDelegates: Boolean = false,
266264
noinline visibility: () -> Boolean = { true },
267265
) = SetSetting(
268266
name,
269267
defaultValue.toMutableSet(),
270268
TypeToken.getParameterized(MutableSet::class.java, T::class.java).type,
271269
description,
272-
hackDelegates,
273270
visibility,
274271
).also {
275272
settings.add(it)

common/src/main/kotlin/com/lambda/config/settings/collections/SetSetting.kt

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
package com.lambda.config.settings.collections
1919

20-
import com.google.gson.JsonElement
21-
import com.lambda.Lambda.gson
2220
import com.lambda.config.AbstractSetting
2321
import java.lang.reflect.Type
2422

@@ -27,27 +25,13 @@ import java.lang.reflect.Type
2725
*/
2826
class SetSetting<T : Any>(
2927
override val name: String,
30-
private val defaultValue: MutableSet<T>,
28+
defaultValue: MutableSet<T>,
3129
type: Type,
3230
description: String,
33-
private val hackDelegates: Boolean,
3431
visibility: () -> Boolean,
3532
) : AbstractSetting<MutableSet<T>>(
3633
defaultValue,
3734
type,
3835
description,
3936
visibility
40-
) {
41-
override fun toJson(): JsonElement {
42-
return if (hackDelegates) gson.toJsonTree(defaultValue, type)
43-
else super.toJson()
44-
}
45-
46-
override fun loadFromJson(serialized: JsonElement) {
47-
if (hackDelegates) {
48-
defaultValue.addAll(gson.fromJson(serialized, type))
49-
setValue(this, ::value, defaultValue.distinct().toMutableSet())
50-
}
51-
else super.loadFromJson(serialized)
52-
}
53-
}
37+
)

0 commit comments

Comments
 (0)