Created
October 13, 2019 22:19
-
-
Save jeffypooo/04a8bc29210e995ceb5ddbc51902cdb7 to your computer and use it in GitHub Desktop.
Misc utilities similar to Kotlin stdlib require funcs
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
package com.beartooth.relaytestapp.util | |
import java.lang.ref.WeakReference | |
/** | |
* Require.kt | |
* author: jefferson jones | |
* org: Beartooth, Inc | |
* github: github.com/masterjefferson | |
* email: [email protected] | |
*/ | |
fun <T: Any> requireReference(weakRef: WeakReference<T>, message: String? = null): T { | |
message ?: return requireNotNull(weakRef.get()) | |
return requireNotNull(weakRef.get()) { message } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment