Skip to content

Commit

Permalink
change: opt-in serializability enforcement on Collection.toSerializab…
Browse files Browse the repository at this point in the history
…leList
  • Loading branch information
jeanbarrossilva committed Aug 21, 2023
1 parent 89a1583 commit c937dfd
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package com.jeanbarrossilva.loadable.list

import com.jeanbarrossilva.loadable.Serializability
import java.io.NotSerializableException

/**
* Converts this [Collection] it into a [SerializableList].
*
* @throws NotSerializableException If any of the elements cannot be serialized.
* @param serializability Determines whether each of the elements should be serializable.
* @throws NotSerializableException If [serializability] is [enforced][Serializability.ENFORCED] and
* any of the elements cannot be serialized.
**/
@Throws(NotSerializableException::class)
inline fun <reified T> Collection<T>.toSerializableList(): SerializableList<T> {
return toTypedArray().toSerializableList()
inline fun <reified T> Collection<T>.toSerializableList(
serializability: Serializability = Serializability.default
): SerializableList<T> {
return toTypedArray().toSerializableList(serializability)
}

0 comments on commit c937dfd

Please sign in to comment.