Skip to content

Instantly share code, notes, and snippets.

@DenisBronx
Last active April 15, 2020 22:08
Show Gist options
  • Save DenisBronx/98b9cad71bf162ca37ae3e8ad4eb6f6f to your computer and use it in GitHub Desktop.
Save DenisBronx/98b9cad71bf162ca37ae3e8ad4eb6f6f to your computer and use it in GitHub Desktop.
Repository Pattern NullableOutputListMapper
// Non-nullable to Nullable
interface NullableOutputListMapper<I, O>: Mapper<List<I>, List<O>?>
class NullableOutputListMapperImpl<I, O>(
private val mapper: Mapper<I, O>
) : NullableOutputListMapper<I, O> {
override fun map(input: List<I>): List<O>? {
return if (input.isEmpty()) null else input.map { mapper.map(it) }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment