Snippets
Snippets
Safe parse to enum
inline fun <reified T: Enum<T>> String.safeEnum(): T? {
return try {
java.lang.Enum.valueOf(T::class.java, this)
} catch (e: IllegalArgumentException) {
null
}
}
Data class mockk shorthand
val model = mockk<ShowcaseDataModel> {
every { offersChangedAt } returns LocalDateTime.now()
every { changedAt } returns LocalDateTime.now()
}