Commit 63b3ca74 authored by Claude Brisson's avatar Claude Brisson

Add copy constructors

parent 098fa087
......@@ -7,7 +7,7 @@ plugins {
}
group = "com.republicate.kson"
version = "1.3"
version = "1.4"
repositories {
mavenCentral()
......
......@@ -300,7 +300,7 @@ interface Json {
/**
*
* Json.Array
*
* Non-copy constructor from a provided mutable list
*/
open class Array(private val lst: MutableList<Any?>) : Json, MutableList<Any?> by lst {
/**
......@@ -308,6 +308,11 @@ interface Json {
*/
constructor() : this(ArrayList())
/**
* Builds a Json.Array from the provided immutable list
*/
constructor(coll: List<*>) : this(ArrayList(coll))
/**
* Builds a Json.Array with specified items
*/
......@@ -602,7 +607,7 @@ interface Json {
/**
*
* Json.Object
*
* Non-copy constructor from a provided mutable map.
*/
open class Object(private val map: MutableMap<String, Any?>) : Json, MutableMap<String, Any?> by map,
Iterable<Map.Entry<String, Any?>> {
......@@ -611,6 +616,11 @@ interface Json {
*/
constructor() : this(LinkedHashMap())
/**
* Builds a Json Object by copying the provided immutable map
*/
constructor(map: Map<String, Any?>) : this(LinkedHashMap(map))
/**
* Builds a Json.Object with specified items
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment