aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2018-08-16 10:23:14 +0200
committerRobert Jaros <rjaros@finn.pl>2018-08-16 10:23:14 +0200
commitd47ea849d13634e4df079dca6caf3697015c51bd (patch)
tree0ecc48c9d2e0a3d1b1ef568a7d74fa102efcdead
parenteddaf3b80f887973380666d8c172ebc0cf238c69 (diff)
downloadkvision-d47ea849d13634e4df079dca6caf3697015c51bd.tar.gz
kvision-d47ea849d13634e4df079dca6caf3697015c51bd.tar.bz2
kvision-d47ea849d13634e4df079dca6caf3697015c51bd.zip
Main dependencies upgrade (Kotlin 1.2.60, coroutines 0.24.0, serialization 0.6.1, frontend plugin 0.0.37, jooby 1.5.0)0.0.15
-rw-r--r--gradle.properties16
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/Form.kt28
2 files changed, 31 insertions, 13 deletions
diff --git a/gradle.properties b/gradle.properties
index 635b6508..bb3ee142 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,14 +1,14 @@
group=pl.treksoft
-version=0.0.14
-kotlinVersion=1.2.41
+version=0.0.15
+kotlinVersion=1.2.60
javaVersion=1.8
-coroutinesVersion=0.22.5
-serializationVersion=0.5.0
-frontendPluginVersion=0.0.30
+coroutinesVersion=0.24.0
+serializationVersion=0.6.1
+frontendPluginVersion=0.0.37
dokkaVersion=0.9.17
-detektVersion=1.0.0.RC7
+detektVersion=1.0.0.RC8
junitVersion=4.12
-joobyVersion=1.3.0
+joobyVersion=1.5.0
kweryVersion=0.17
dependencyManagementPluginVersion=1.0.4.RELEASE
-jacksonModuleKotlinVersion=2.9.5
+jacksonModuleKotlinVersion=2.9.6
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/Form.kt b/src/main/kotlin/pl/treksoft/kvision/form/Form.kt
index 18acdf9f..b1e08606 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/Form.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/Form.kt
@@ -42,6 +42,24 @@ internal data class FieldParams<in F : FormControl>(
)
/**
+ * A wrapper for a Map with a custom containsKey method implementation.
+ * Used with kotlinx.serialization Mapper.
+ */
+private class FormMapWrapper<out V>(private val map: Map<String, V>) : Map<String, V> {
+ override fun equals(other: Any?): Boolean = map == other
+ override fun hashCode(): Int = map.hashCode()
+ override fun toString(): String = map.toString()
+ override val size: Int get() = map.size
+ override fun isEmpty(): Boolean = map.isEmpty()
+ override fun containsKey(key: String): Boolean = if (key.indexOf('.') != -1) map.containsKey(key) else !(map.containsKey("$key.time") || map.containsKey("$key.size"))
+ override fun containsValue(value: @UnsafeVariance V): Boolean = map.containsValue(value)
+ override fun get(key: String): V? = map[key]
+ override val keys: Set<String> get() = map.keys
+ override val values: Collection<V> get() = map.values
+ override val entries: Set<Map.Entry<String, V>> get() = map.entries
+}
+
+/**
* The form definition class. Can be used directly or indirectly inside a [FormPanel].
*
* @constructor Creates a form with a given modelFactory function
@@ -67,9 +85,9 @@ class Form<K : Any>(private val panel: FormPanel<K>? = null, private val seriali
}
is List<*> -> {
@Suppress("UNCHECKED_CAST")
- (entry.value as? List<KFile>)?.let {
- listOf(entry.key to entry.value, "${entry.key}.size" to it.size) +
- it.mapIndexed { index, kFile ->
+ (entry.value as? List<KFile>)?.let { list ->
+ listOf(entry.key to entry.value, "${entry.key}.size" to list.size) +
+ list.mapIndexed { index, kFile ->
listOf(
"${entry.key}.${index + 1}.name" to kFile.name,
"${entry.key}.${index + 1}.size" to kFile.size,
@@ -80,8 +98,8 @@ class Form<K : Any>(private val panel: FormPanel<K>? = null, private val seriali
}
else -> listOf(entry.key to entry.value)
}
- }.toMap().withDefault { null }
- val mapper = Mapper.InNullableMapper(map)
+ }.toMap()
+ val mapper = Mapper.InNullableMapper(FormMapWrapper(map))
mapper.read(serializer)
}
}