Last active
March 5, 2018 06:56
-
-
Save GiorgioNatili/67d722b043064a510caffb0772cf949a to your computer and use it in GitHub Desktop.
Run a lambda only when the objects don't contain a null property
This file contains hidden or 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
package io.a2xe.experiments.selfielifecycle.utilities | |
/** | |
* Created by giorgio on 3/4/18. | |
*/ | |
fun <T:Any> whenNotNullObjects(vararg args: T?, action: () -> Unit) { | |
args.forEach {target -> | |
checkNotNull(target) { | |
target!!::class.java.declaredFields.forEach { | |
if(it.get(target) == null) { | |
return | |
} | |
} | |
} | |
} | |
action() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment