Skip to main content

Custom TypeParser

If you want to create your own TypeParser, you can do so by implementing the IStringTypeParser interface.

class UUIDParser : IStringTypeParser<UUID> {
override fun parse(value: String): UUID {
return UUID.fromString(value)
}

override fun allowedTypes(): List<Class<out UUID>> {
return listOf(UUID::class.java)
}
}

How to use

To use your custom TypeParser, you need to register it the StringParser object.

StringParser.customTypeParsers.add(UUIDParser())