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

com.zeoflow.depot.compiler.processing.InternalXAnnotated.kt Maven / Gradle / Ivy

Go to download

The Depot persistence library provides an abstraction layer over SQLite to allow for more robust database access while using the full power of SQLite.

There is a newer version: 1.0.5
Show newest version
/*
 * Copyright (C) 2021 ZeoFlow SRL
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.zeoflow.depot.compiler.processing

import kotlin.reflect.KClass

/**
 * Internal API for [XAnnotated] that handles repeated annotations.
 */
internal interface InternalXAnnotated : com.zeoflow.depot.compiler.processing.XAnnotated {
    /**
     * Repeated annotations show up differently between source and .class files.
     *
     * To avoid that inconsistency, [XAnnotated] only provides [XAnnotated.getAnnotations] and in
     * this internal wrapper, we handle that inconsistency by finding the container class and
     * asking implementers to implement the 2 arg version instead.
     *
     * see: https://github.com/google/ksp/issues/356
     * see: https://github.com/google/ksp/issues/358
     * see: https://youtrack.jetbrains.com/issue/KT-12794
     *
     * @param annotation The annotation to query
     * @param containerAnnotation The container annotation of the [annotation] if it is a repeatable
     * annotation.
     *
     * @see hasAnnotation
     */
    fun  getAnnotations(
        annotation: KClass,
        containerAnnotation: KClass? = annotation.containerAnnotation
    ): List>

    override fun  getAnnotations(annotation: KClass) = getAnnotations(
        annotation = annotation,
        containerAnnotation = annotation.containerAnnotation
    )

    override fun hasAnnotation(annotation: KClass) = hasAnnotation(
        annotation = annotation,
        containerAnnotation = annotation.containerAnnotation
    )

    /**
     * Returns `true` if this element is annotated with the given [annotation].
     *
     * Note that this method should check for both [annotation] and [containerAnnotation] to
     * support repeated annotations.
     *
     * @param annotation The annotation to query
     * @param containerAnnotation The container annotation of the [annotation] if it is a repeatable
     * annotation.
     *
     * @see [toAnnotationBox]
     * @see [hasAnyOf]
     */
    fun hasAnnotation(
        annotation: KClass,
        containerAnnotation: KClass? = annotation.containerAnnotation
    ): Boolean
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy