-
Notifications
You must be signed in to change notification settings - Fork 0
Utilities
Roman Makeev edited this page Nov 17, 2022
·
2 revisions
This page contains basic utilities of AstraLibs
With AstraLibs you can easily iterate through enums
// ktx_core_ext.kt
enum class MyEnum{
FIRST,SECOND,THIRD
}
fun nextEnum(){
val myEnumInstance = MyEnum.FIRST
myEnumInstance.next() // MyEnum.Second
myEnumInstance.addIndex(2) // MyEnum.Third
valueOfOrNull<MyEnum>(FIRST) // MyEnum.First
}
// ReflectionUtil.kt
class MyClass(var customValue: Int)
ReflectionUtil.getDeclaredField(MyClass::class.java,"customValue")
val myClassInstance = MyClass(0)
ReflectionUtil.setDeclaredField(MyClass::class.java,myClassInstance, "customValue", 10)