aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/model/extraModifiers.kt
blob: 093ce62af724f23405cd9b437e09bf40d0bb4eea (plain)
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
53
54
55
56
57
58
59
60
package org.jetbrains.dokka.model

sealed class ExtraModifiers(val name: String) {

    sealed class KotlinOnlyModifiers(name: String) : ExtraModifiers(name) {
        object Inline : KotlinOnlyModifiers("inline")
        object Infix : KotlinOnlyModifiers("infix")
        object External : KotlinOnlyModifiers("external")
        object Suspend : KotlinOnlyModifiers("suspend")
        object Reified : KotlinOnlyModifiers("reified")
        object CrossInline : KotlinOnlyModifiers("crossinline")
        object NoInline : KotlinOnlyModifiers("noinline")
        object Override : KotlinOnlyModifiers("override")
        object Data : KotlinOnlyModifiers("data")
        object Const : KotlinOnlyModifiers("const")
        object Inner : KotlinOnlyModifiers("inner")
        object LateInit : KotlinOnlyModifiers("lateinit")
        object Operator : KotlinOnlyModifiers("operator")
        object TailRec : KotlinOnlyModifiers("tailrec")
        object VarArg : KotlinOnlyModifiers("vararg")
    }

    sealed class JavaOnlyModifiers(name: String) : ExtraModifiers(name) {
        object Static : JavaOnlyModifiers("static")
        object Native : JavaOnlyModifiers("native")
        object Synchronized : JavaOnlyModifiers("synchronized")
        object StrictFP : JavaOnlyModifiers("strictfp")
        object Transient : JavaOnlyModifiers("transient")
        object Volatile : JavaOnlyModifiers("volatile")
        object Transitive : JavaOnlyModifiers("transitive")
    }
    
    companion object {
        fun valueOf(str: String) = when(str) {
            "inline" -> KotlinOnlyModifiers.Inline
            "infix" -> KotlinOnlyModifiers.Infix
            "external" -> KotlinOnlyModifiers.External
            "suspend" -> KotlinOnlyModifiers.Suspend
            "reified" -> KotlinOnlyModifiers.Reified
            "crossinline" -> KotlinOnlyModifiers.CrossInline
            "noinline" -> KotlinOnlyModifiers.NoInline
            "override" -> KotlinOnlyModifiers.Override
            "data" -> KotlinOnlyModifiers.Data
            "const" -> KotlinOnlyModifiers.Const
            "inner" -> KotlinOnlyModifiers.Inner
            "lateinit" -> KotlinOnlyModifiers.LateInit
            "operator" -> KotlinOnlyModifiers.Operator
            "tailrec" -> KotlinOnlyModifiers.TailRec
            "vararg" -> KotlinOnlyModifiers.VarArg
            "static" -> JavaOnlyModifiers.Static
            "native" -> JavaOnlyModifiers.Native
            "synchronized" -> JavaOnlyModifiers.Synchronized
            "strictfp" -> JavaOnlyModifiers.StrictFP
            "transient" -> JavaOnlyModifiers.Transient
            "volatile" -> JavaOnlyModifiers.Volatile
            "transitive" -> JavaOnlyModifiers.Transitive
            else -> throw IllegalArgumentException("There is no Extra Modifier for given name $str")
        }
    }
}