Updated version
This commit is contained in:
parent
dea06594e9
commit
41f82fb33e
|
@ -11,7 +11,7 @@ Maven Info
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.dorkbox</groupId>
|
<groupId>com.dorkbox</groupId>
|
||||||
<artifactId>Serializers</artifactId>
|
<artifactId>Serializers</artifactId>
|
||||||
<version>2.6</version>
|
<version>2.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
```
|
```
|
||||||
|
|
|
@ -37,7 +37,7 @@ object Extras {
|
||||||
// set for the project
|
// set for the project
|
||||||
const val description = "Kryo based serializers"
|
const val description = "Kryo based serializers"
|
||||||
const val group = "com.dorkbox"
|
const val group = "com.dorkbox"
|
||||||
const val version = "2.6"
|
const val version = "2.7"
|
||||||
|
|
||||||
// set as project.ext
|
// set as project.ext
|
||||||
const val name = "Serializers"
|
const val name = "Serializers"
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
package dorkbox.serializers
|
package dorkbox.serializers
|
||||||
|
|
||||||
import com.esotericsoftware.kryo.Kryo
|
import com.esotericsoftware.kryo.Kryo
|
||||||
|
import com.esotericsoftware.kryo.Registration
|
||||||
|
import com.esotericsoftware.kryo.Serializer
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.math.BigDecimal
|
import java.math.BigDecimal
|
||||||
|
@ -31,7 +33,7 @@ object SerializationDefaults {
|
||||||
/**
|
/**
|
||||||
* Gets the version number.
|
* Gets the version number.
|
||||||
*/
|
*/
|
||||||
const val version = "2.6"
|
const val version = "2.7"
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// Add this project to the updates system, which verifies this class + UUID + version information
|
// Add this project to the updates system, which verifies this class + UUID + version information
|
||||||
|
@ -54,6 +56,27 @@ object SerializationDefaults {
|
||||||
val inet6AddressSerializer by lazy { Inet6AddressSerializer() }
|
val inet6AddressSerializer by lazy { Inet6AddressSerializer() }
|
||||||
val fileSerializer by lazy { FileSerializer() }
|
val fileSerializer by lazy { FileSerializer() }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows for the kryo registration of sensible defaults in a common, well-used way. Uses a hashmap to return registration data
|
||||||
|
*/
|
||||||
|
fun register(): MutableMap<Class<*>, Serializer<*>?> {
|
||||||
|
val registeredClasses: MutableMap<Class<*>, Serializer<*>?> = mutableMapOf()
|
||||||
|
val kryo = object : Kryo() {
|
||||||
|
override fun register(type: Class<*>): Registration {
|
||||||
|
registeredClasses[type] = null
|
||||||
|
return super.register(type)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun register(type: Class<*>, serializer: Serializer<*>?): Registration {
|
||||||
|
registeredClasses[type] = serializer
|
||||||
|
return super.register(type, serializer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
register(kryo)
|
||||||
|
return registeredClasses
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows for the kryo registration of sensible defaults in a common, well-used way.
|
* Allows for the kryo registration of sensible defaults in a common, well-used way.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue