Created
December 14, 2017 12:36
-
-
Save FilipeLipan/47022778cef0f2c2a3e8b2803b4ad792 to your computer and use it in GitHub Desktop.
reflection example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bundle = Bundle() | |
bundle.putString("este é um teste com bundles", "this a call to all my past resignations") | |
bundle.putInt("quantidade de cupons", 1) | |
bundle.putLong("", 1) | |
val userProperty = UserProperty(name = "fil", email = "test", extra = bundle); | |
for (prop in UserProperty::class.memberProperties) { | |
prop.get(userProperty)?.let { | |
if(prop.returnType.jvmErasure.isSubclassOf(Bundle::class)){ | |
(prop.get(userProperty) as Bundle).keySet().forEach { | |
val objectInsideTheKey = (prop.get(userProperty) as Bundle).get(it) | |
Log.d("${it} = ${objectInsideTheKey.toString()}", "teste") | |
} | |
}else{ | |
Log.d("${prop.name} = ${prop.get(userProperty)}", "teste") | |
} | |
} | |
} | |
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment