diff --git a/pact-jvm-mock/src/main/kotlin/io/github/ludorival/pactjvm/mock/Pact.kt b/pact-jvm-mock/src/main/kotlin/io/github/ludorival/pactjvm/mock/Pact.kt index 1a3707f..0717870 100644 --- a/pact-jvm-mock/src/main/kotlin/io/github/ludorival/pactjvm/mock/Pact.kt +++ b/pact-jvm-mock/src/main/kotlin/io/github/ludorival/pactjvm/mock/Pact.kt @@ -39,7 +39,8 @@ data class Pact( ) { @JsonIgnore - inline fun body() : T? = if (body is T) body else null + @Suppress("UNCHECKED_CAST") + fun body() : T? = body as? T enum class Method { GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE } diff --git a/pact-jvm-mock/src/main/kotlin/io/github/ludorival/pactjvm/mock/Utils.kt b/pact-jvm-mock/src/main/kotlin/io/github/ludorival/pactjvm/mock/Utils.kt index b551083..e689f5c 100644 --- a/pact-jvm-mock/src/main/kotlin/io/github/ludorival/pactjvm/mock/Utils.kt +++ b/pact-jvm-mock/src/main/kotlin/io/github/ludorival/pactjvm/mock/Utils.kt @@ -5,13 +5,13 @@ import com.fasterxml.jackson.databind.JsonSerializer import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.SerializerProvider -inline fun serializerWith(crossinline supplier: (JsonGenerator) -> Unit) = object : JsonSerializer() { + fun serializerWith( supplier: (JsonGenerator) -> Unit) = object : JsonSerializer() { override fun serialize(value: T, gen: JsonGenerator, serializers: SerializerProvider?) { supplier(gen) } } -inline fun serializerAsDefault(defaultValue: String) = +fun < T> serializerAsDefault(defaultValue: String) = serializerWith { it.writeString(defaultValue) }