/
StartupConfig.kt
52 lines (42 loc) 路 1.35 KB
/
StartupConfig.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.rousetime.android_startup.model
import com.rousetime.android_startup.StartupListener
/**
* Created by idisfkj on 2020/7/31.
* Email: idisfkj@gmail.com.
*/
class StartupConfig private constructor(
val loggerLevel: LoggerLevel,
val awaitTimeout: Long,
val listener: StartupListener?,
val openStatistic: Boolean? = true
) {
class Builder {
private var mLoggerLevel: LoggerLevel? = null
private var mAwaitTimeout: Long? = null
private var mListener: StartupListener? = null
private var mOpenStatistics: Boolean? = true
companion object {
const val AWAIT_TIMEOUT = 10000L
}
fun setLoggerLevel(level: LoggerLevel) = apply {
mLoggerLevel = level
}
fun setAwaitTimeout(timeoutMilliSeconds: Long) = apply {
mAwaitTimeout = timeoutMilliSeconds
}
fun setListener(listener: StartupListener) = apply {
mListener = listener
}
fun setOpenStatistics(openStatistic: Boolean) = apply {
mOpenStatistics = openStatistic
}
fun build(): StartupConfig {
return StartupConfig(
mLoggerLevel ?: LoggerLevel.NONE,
mAwaitTimeout ?: AWAIT_TIMEOUT,
mListener,
mOpenStatistics
)
}
}
}