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
/** | |
* Guard let in Kotlin | |
**/ | |
inline infix fun <reified T> T?.guard(call: () -> Unit): T? { | |
if (this is T) return this | |
else { | |
call() | |
return null | |
} | |
} |
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
public final class WeakRefUtil { | |
/** | |
* Safely unwrap a WeakReference<T> | |
* | |
* Returns reference if unwrapped or null | |
* @param reference - WeakReference<T> | |
* @return T | |
*/ | |
@Nullable |