Skip to content

Commit

Permalink
Merge pull request #49 from jeanbarrossilva/change/opt-in-to-serializ…
Browse files Browse the repository at this point in the history
…ability-enforcement-on-collection-to-serializability-list-converter

Opt-in serializability enforcement on `Collection#toSerializableList`
  • Loading branch information
jeanbarrossilva authored Aug 21, 2023
2 parents 89a1583 + c937dfd commit d650495
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 d650495

Please sign in to comment.