How can I avoid repeating the same annotation arguments everywhere?

I'm using an annotation from a library that requires a list of arguments, and there are a lot of classes throughout my project that use this annotation with those exact same arguments.

@AnnotationFromDependency(values = [long, list, of, variables, that, might, change])
class Foo {
    fun bar() {
        println("dostuff")
    }
}

How can I avoid copying the same arguments for @AnnotationDependency to every class that uses it? Defining the arguments list in a variable does not work because it is not a compile-time constant.

val myValues = arrayOf("long", "list", "of", "values", "that", "might", "change")

@AnnotationFromDependency(values = myValues) // error: An annotation argument must be a compile-time constant
class Foo {
    fun bar() {
        println("dostuff")
    }
}


Read more here: https://stackoverflow.com/questions/65703144/how-can-i-avoid-repeating-the-same-annotation-arguments-everywhere

Content Attribution

This content was originally published by ZeitPolizei at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: