Can delegation be used to set these values at declaration time (thus reducing lines)? This class represents a single entry in a log file of the Common Log Format. Can this be improved? I think I might be able to use delegation to pluck values from the matcher. Ideally I would be able to set these values at declaration time. 

Kotlin code 

    data class CommonLogEntry(private val entry: String) {
        companion object {
            private val formatter: DateTimeFormatter = DateTimeFormatter.ofPattern("dd/MMM/yyyy:HH:mm:ss Z")
            private fun asDateTime(line: String) = LocalDateTime.parse(line, formatter)
            val pattern: String = "^(\\S+) (\\S+) (\\S+) \\[([\\w:/]+\\s[+\\-]\\d{4})] \"(\\S+) (\\S+)\\s*(\\S+)?\\s*\" (\\d{3}) (\\d+) \"(\\S+)\" \"(\\S+)\""
        }

        val clientIp: String
        val rfc1413identity: String
        val identity: String
        val requestTime: LocalDateTime
        val verb: String
        val resource: String
        val httpVersion: String
        val statusCode: Int
        val payloadSize: Long
        val URI: URI
        val userAgent: String

        init {
            val p = Pattern.compile(pattern)
            val m = p.matcher(entry)
            if (!m.matches() || m.groupCount() != 11)
                throw IllegalArgumentException("Log Pattern doesn't match '$pattern'")

            clientIp = m.group(1)
            rfc1413identity = m.group(2)
            identity = m.group(3)
            requestTime = asDateTime(m.group(4))
            verb = m.group(5)
            resource = m.group(6)
            httpVersion = m.group(7)
            statusCode = m.group(8).toInt()
            payloadSize = m.group(9).toLong()
            URI = java.net.URI.create(m.group(10))
            userAgent = m.group(11)
        }
    }
By moving a few things around you could easily get rid of the init block, shortening the amount of lines.

Key parts is to move the Pattern to the companion object, and use .also on the matcher to make sure it is a correct match.

data class CommonLogEntry(private val entry: String) {
    companion object {
        private val formatter: DateTimeFormatter = DateTimeFormatter.ofPattern("dd/MMM/yyyy:HH:mm:ss Z")
        private fun asDateTime(line: String) = LocalDateTime.parse(line, formatter)
        val pattern: Pattern = Pattern.compile("^(\\S+) (\\S+) (\\S+) \\[([\\w:/]+\\s[+\\-]\\d{4})] \"(\\S+) (\\S+)\\s*(\\S+)?\\s*\" (\\d{3}) (\\d+) \"(\\S+)\" \"(\\S+)\"")
    }

    private val m = pattern.matcher(entry).also {
        if (!it.matches() || it.groupCount() != 11)
            throw IllegalArgumentException("Log Pattern doesn't match '$pattern'")
    }
    val clientIp: String = m.group(1)
    val rfc1413identity: String = m.group(2)
    val identity: String = ...
    val requestTime: LocalDateTime = ...
    val verb: String = ...
    val resource: String = ...
    val httpVersion: String = ...
    val statusCode: Int = ...
    val payloadSize: Long = ...
    val URI: URI = ...
    val userAgent: String = ...


However, I have to question the reason for writing this code. I have a feeling there is already some library out there that can parse these log files, it is the "Common Log Format" after all. Also, if you want to parse log files in general I would strongly recommend the tool Splunk which does have a free license for up to 500 MB of logs per day.