diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index bec3af2f1..aa1b8e95d 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -42,6 +42,11 @@ import kotlin.properties.ReadWriteProperty import kotlin.reflect.KMutableProperty1 import kotlin.reflect.KProperty import kotlin.reflect.KProperty0 +import kotlin.reflect.KProperty1 +import kotlin.reflect.full.isSubtypeOf +import kotlin.reflect.full.memberProperties +import kotlin.reflect.full.starProjectedType +import kotlin.reflect.jvm.isAccessible import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds @@ -501,6 +506,14 @@ object LorenzUtils { } } + inline fun <reified T : Any> Any.getPropertiesWithType() = + this::class.memberProperties + .filter { it.returnType.isSubtypeOf(T::class.starProjectedType) } + .map { + it.isAccessible = true + (it as KProperty1<Any, T>).get(this) + } + fun List<String>.nextAfter(after: String, skip: Int = 1) = nextAfter({ it == after }, skip) fun List<String>.nextAfter(after: (String) -> Boolean, skip: Int = 1): String? { |