map.getOrPut() method to avoid the suppress warning annotation

This commit is contained in:
2016-10-20 19:50:42 +02:00
parent 2af617d576
commit a386abe617

View File

@@ -85,11 +85,9 @@ class Converter(val name: String) {
}
@Suppress("UNCHECKED_CAST")
fun constraint(column : JsonObject, key : String, value: Any?) {
if (value == null) return
val constraints = column["constraints"] as JsonObject? ?: JsonObject(HashMap<String, Any>())
column["constraints"] = constraints
val constraints = column.getOrPut("constraints") { JsonObject(mutableMapOf()) } as JsonObject
constraints[key] = value
}