SingleDelegate
- @Retention(RetentionPolicy.SOURCE)
- @Target(ElementType.TYPE)
- public @interface SingleDelegate {
- /**
- * impl class name
- */
- String classNameImpl();
- /**
- * delegate data
- */
- Delegate delegate();
- }
MultiDelegate
- @Retention(RetentionPolicy.SOURCE)
- @Target(ElementType.TYPE)
- public @interface MultiDelegate {
- /**
- * impl class name
- */
- String classNameImpl();
- /**
- * delegate list
- */
- Delegate[] Delegates();
- }
处理自定义的注解、生成代码
AnnotationProcessor
- @AutoService(Processor.class) // javax.annotation.processing.IProcessor
- @SupportedSourceVersion(SourceVersion.RELEASE_7) //java
- @SupportedAnnotationTypes({ // 标注注解处理器支撑的注解类型
- "com.annotation.SingleDelegate",
- "com.annotation.MultiDelegate"
- })
- public class AnnotationProcessor extends AbstractProcessor {
- public static final String PACKAGE = "com.poet.delegate";
- public static final String CLASS_DESC = "From poet compiler";
- public Filer filer; //文件相干的帮助类
- public Elements elements; //元素相干的帮助类
- public Messager messager; //日记相干的帮助类
- public Types types;
- @Override
- public boolean process(Set<? extends TypeElement> set, RoundEnvironment roundEnvironment) {
- filer = processingEnv.getFiler();
- elements = processingEnv.getElementUtils();
- messager = processingEnv.getMessager();
推荐阅读
沙龙晃荡 | 去哪儿、陌陌、ThoughtWorks在主动化运维中的实践!10.28不见不散!大年夜多半公共云都可以应用机械进修,这些供给了企业须要的人工智能的才能。就像深度进修一样,云计算让人工智能从新焕发>>>详细阅读
地址:http://www.17bianji.com/lsqh/37959.html
1/2 1