Using Reflection i want to get only public members


#1

Using Reflection i want to get only public members:

class MyClass
{
public var pubVar = "pubVar"
private var pvtVar = “pvtVar”
}

(MyClass::class.declaredMemberProperties) lists both public & private members.
How to get only public members?


#2

Check the visibility of its getter:

MyClass::class.declaredMemberProperties.filter { it.getter.visibility == KVisibility.PUBLIC }