@Retention(value=SOURCE) @Target(value=TYPE) public @interface DataEnum
To be used together with the dataenum-processor annotation processor.
This annotation must be used on a package private interface, and the interface name must end
with '_dataenum'. For each value of the enum, declare a method with dataenum_case
as the
return type. The name of the method will be used as the name of the value type, and the arguments
of the method will be the data associated with the value.
The value names are taken verbatim from the interface, so you will want to use CamelCase for the value names. Non-primitive types will be non-nullable by default, but this can be overriden using a @Nullable annotation.
A new class will be generated without the `_dataenum` suffix, and that will be your data enumeration class. It will act as a factory and a base class for your enumeration values. The interface that has the @DataEnum annotation is only used as an input for code generation, therefore all classes with the `_dataenum` suffix can be excluded from artifacts.
@DataEnum interface MyData_dataenum { dataenum_case Foo(int justANumber, String stringThatCannotBeNull); dataenum_case Bar(@Nullable String thisStringCanBeNull); dataenum_case Baz(); // no data associated with this value }
Copyright © 2023. All rights reserved.