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

com.ybo.trackingplugin.tasks.data.TraceAnnotationMark.kt Maven / Gradle / Ivy

Go to download

gradle plugin allowing to add automatic logs (or other process) at the start of each traced method

There is a newer version: 0.6.2
Show newest version
package com.ybo.trackingplugin.tasks.data

import org.gradle.api.GradleException

/** represents a annotation that user put on a method */
class TraceAnnotationMark(
    private val wholeClass: String?,
    val language: TracedLanguage,
) {
    val shortVersion: String
        get() {
            if (wholeClass == null) {
                throw GradleException("no trace annotation defined")
            } else if (!wholeClass.contains(".")) {
                throw GradleException("trace annotation must have the whole package")
            } else if (wholeClass.endsWith(".")) {
                throw GradleException("trace annotation is not well formatted ($wholeClass)")
            }
            return "@" + wholeClass.substring(wholeClass.lastIndexOf('.')+1)
        }

    val longVersion: String
        get() {
            if (wholeClass == null) {
                throw GradleException("no trace annotation defined")
            } else if (!wholeClass.contains(".")) {
                throw GradleException("trace annotation must have the whole package")
            } else if (wholeClass.endsWith(".")) {
                throw GradleException("trace annotation is not well formatted ($wholeClass)")
            }
            return "@$wholeClass"
        }

    val importStatement: String
        get() = ("import $wholeClass") + when (language) {
            TracedLanguage.JAVA -> ";"
            TracedLanguage.KOTLIN -> ""
            TracedLanguage.OTHER -> ""
        }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy