Skip to content

Commit

Permalink
Merge pull request #57 from nadraliev/version-increment
Browse files Browse the repository at this point in the history
Version increment
  • Loading branch information
ashcherbakov authored Jun 1, 2022
2 parents f7906c3 + 54e8dae commit 37203a3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official

version=0.3.0
version=0.3.1
group=org.didcommx

kotlinJvm=1.5.21
Expand Down
5 changes: 2 additions & 3 deletions lib/src/main/kotlin/org/didcommx/didcomm/utils/JSONUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ package org.didcommx.didcomm.utils

import com.google.gson.GsonBuilder
import com.google.gson.reflect.TypeToken
import com.nimbusds.jose.shaded.json.JSONArray
import com.nimbusds.jose.util.JSONObjectUtils
import org.didcommx.didcomm.exceptions.MalformedMessageException

inline fun <reified T> Map<String, Any?>.getTypedArray(key: String): Array<T?>? = this[key]?.let {
if (it !is JSONArray) throw MalformedMessageException("The expected type of header '$key' is 'JSONArray'. Got '${it::class.simpleName}'")
if (it !is List<*>) throw MalformedMessageException("The expected type of header '$key' is 'List'. Got '${it::class.simpleName}'")
else it.getTyped(key)
}

Expand All @@ -16,7 +15,7 @@ inline fun <reified T> Map<String, Any?>.getTyped(key: String): T? = this[key]?.
else it
}

inline fun <reified T> JSONArray.getTyped(key: String): Array<T?> = this.map {
inline fun <reified T> List<*>.getTyped(key: String): Array<T?> = this.map {
when (it) {
null -> null
!is T -> throw MalformedMessageException("The expected type of header '$key' is '${T::class.simpleName}'. Got '${it::class.simpleName}'")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ class JWM {
"attachments": "131"
}
""".trimIndent(),
"The expected type of header 'attachments' is 'JSONArray'. Got 'String'"
"The expected type of header 'attachments' is 'List'. Got 'String'"
),

WrongMessage(
Expand Down

0 comments on commit 37203a3

Please sign in to comment.