All Downloads are FREE. Search and download functionalities are using the official Maven repository.

kotlinx.metadata.annotations.kt Maven / Gradle / Ivy

/*
 * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
 * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
 */

package kotlinx.metadata

/**
 * Represents an annotation, written to the Kotlin metadata. Note that not all annotations are written to metadata on all platforms.
 * For example, on JVM most of the annotations are written directly on the corresponding declarations in the class file,
 * and entries in the metadata only have a flag ([Flag.HAS_ANNOTATIONS]) to signal if they do have annotations in the bytecode.
 * On JVM, only annotations on type parameters and types are serialized to the Kotlin metadata.
 *
 * @param className the fully qualified name of the annotation class
 * @param arguments explicitly specified arguments to the annotation; does not include default values for annotation parameters
 *                  (specified in the annotation class declaration)
 */
data class KmAnnotation(val className: ClassName, val arguments: Map>)

/**
 * Represents an argument to the annotation.
 *
 * @param T the type of the value of this argument
 */
sealed class KmAnnotationArgument {
    /**
     * The value of this argument.
     */
    abstract val value: T

    data class ByteValue(override val value: Byte) : KmAnnotationArgument()
    data class CharValue(override val value: Char) : KmAnnotationArgument()
    data class ShortValue(override val value: Short) : KmAnnotationArgument()
    data class IntValue(override val value: Int) : KmAnnotationArgument()
    data class LongValue(override val value: Long) : KmAnnotationArgument()
    data class FloatValue(override val value: Float) : KmAnnotationArgument()
    data class DoubleValue(override val value: Double) : KmAnnotationArgument()
    data class BooleanValue(override val value: Boolean) : KmAnnotationArgument()

    data class UByteValue(override val value: Byte) : KmAnnotationArgument()
    data class UShortValue(override val value: Short) : KmAnnotationArgument()
    data class UIntValue(override val value: Int) : KmAnnotationArgument()
    data class ULongValue(override val value: Long) : KmAnnotationArgument()

    data class StringValue(override val value: String) : KmAnnotationArgument()
    data class KClassValue(override val value: ClassName) : KmAnnotationArgument()
    data class EnumValue(val enumClassName: ClassName, val enumEntryName: String) : KmAnnotationArgument() {
        override val value: String = "$enumClassName.$enumEntryName"
    }

    data class AnnotationValue(override val value: KmAnnotation) : KmAnnotationArgument()
    data class ArrayValue(override val value: List>) : KmAnnotationArgument>>()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy