What would be the equivalent of the following annotation usage in kotlin:
@TypeDefs({
@TypeDef(name = "string-array", typeClass = StringArrayType.class),
@TypeDef(name = "int-array", typeClass = IntArrayType.class),
@TypeDef(name = "json", typeClass = JsonStringType.class),
@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
})
This is the definition of @TypeDefs
@Target({TYPE, PACKAGE})
@Retention(RUNTIME)
public @interface TypeDefs {
/**
* The grouping of type definitions.
*/
TypeDef[] value();
}
public class Foo {...}
and this is the one of @TypeDef
@Target({TYPE, PACKAGE})
@Retention(RUNTIME)
@Repeatable(TypeDefs.class)
public @interface TypeDef {
/**
* The type name. This is the name that would be used in other locations.
*/
String name() default "";
/**
* The type implementation class.
*/
Class<?> typeClass();
/**
* Name a java type for which this defined type should be the default mapping.
*/
Class<?> defaultForType() default void.class;
/**
* Any configuration parameters for this type definition.
*/
Parameter[] parameters() default {};
}
I tried using arrayOf()
but it's not working.
@TypeDefs(arrayOf(
@TypeDef(name = "string-array", typeClass = StringArrayType::class),
@TypeDef(name = "int-array", typeClass = IntArrayType::class),
@TypeDef(name = "json", typeClass = JsonStringType::class),
@TypeDef(name = "jsonb", typeClass = JsonBinaryType::class)
))
data class Foo (...)
I'm getting the following error on IntelliJ Idea: An annotation cannot be used as the annotations argument