Skip to content

Parsers

Javier Diaz edited this page Aug 19, 2018 · 4 revisions

A parser is what knows how to convert from ConfigObject to T where T is any type. It is really simple:

object IntParser : Parser<Int> {
    override fun parse(value: ConfigObject, type: Class<*>, parser: Parser<*>?): Int {
        return value.asString().toInt()
    }
}

After that, register your parser in Parsers class, method addParser()


List of the types supported out of the box:

  1. Int
  2. Long
  3. Double
  4. Short
  5. Float
  6. Double
  7. Byte
  8. String
  9. Boolean
  10. List
  11. Set
  12. Enum
  13. BigInteger
  14. BigDecimal
  15. LocalDateTime
  16. LocalDate
  17. ZonedDateTime
  18. OffsetDateTime
  19. OffsetTime
  20. Calendar
  21. Date
  22. URI
  23. URL
  24. File
  25. Path
  26. Class<*>
  27. Regex
  28. Pattern
  29. InetAddress
  30. Connection
  31. Driver
  32. UUID
Clone this wiki locally