@Test public void testTuneAnnotations(@TuneProvider(ANNOTATIONS) Tune tune) { TypeSpec.Builder builder = TypeSpec.classBuilder("Test"); TypeModel model = new TypeModel(); new ClassAnnotationHandler(tune, null, null).process(builder, model); TypeSpec spec = builder.build(); assertEquals("Test", spec.name, "Wrong class found"); assertEquals(2, spec.annotations.size(), "Annotations found"); }
@Override public void process(TypeSpec.Builder typeSpec, TypeModel typeModel) { List<AnnotationModel> classAnnotations = consolidateClassAnnotations(tune, typeModel); for (AnnotationModel model : classAnnotations) { ClassName annotationName = getClassName(model.getClassName()); AnnotationSpec.Builder annotationBuilder = AnnotationSpec.builder(annotationName); Optional.ofNullable(model.getMembers()).map(Map::entrySet) .ifPresent(entries -> entries.forEach(entry -> annotationBuilder.addMember(entry.getKey(), entry.getValue()))); typeSpec.addAnnotation(annotationBuilder.build()); } }
ClassAnnotationHandler extends Handler { @Override public void process(TypeSpec.Builder typeSpec, TypeModel typeModel) { List<AnnotationModel> classAnnotations = consolidateClassAnnotations(tune, typeModel); for (AnnotationModel model : classAnnotations) { ClassName annotationName = getClassName(model.getClassName()); AnnotationSpec.Builder annotationBuilder = AnnotationSpec.builder(annotationName); Optional.ofNullable(model.getMembers()).map(Map::entrySet) .ifPresent(entries -> entries.forEach(entry -> annotationBuilder.addMember(entry.getKey(), entry.getValue()))); typeSpec.addAnnotation(annotationBuilder.build()); } } }
ClassAnnotationHandler extends Handler { @Override public void process(TypeSpec.Builder typeSpec, TypeModel typeModel) { List<AnnotationModel> classAnnotations = consolidateClassAnnotations(tune, typeModel); for (AnnotationModel model : classAnnotations) { ClassName annotationName = getClassName(model.getClassName()); AnnotationSpec.Builder annotationBuilder = AnnotationSpec.builder(annotationName); Optional.ofNullable(model.getMembers()).map(Map::entrySet) .ifPresent(entries -> entries.forEach(entry -> annotationBuilder.addMember(entry.getKey(), entry.getValue()))); typeSpec.addAnnotation(annotationBuilder.build()); } } ClassAnnotationHandler(Tune tune, MetaInfo metaInfo, RuleSet ruleSet); }
ClassAnnotationHandler extends Handler { @Override public void process(TypeSpec.Builder typeSpec, TypeModel typeModel) { List<AnnotationModel> classAnnotations = consolidateClassAnnotations(tune, typeModel); for (AnnotationModel model : classAnnotations) { ClassName annotationName = getClassName(model.getClassName()); AnnotationSpec.Builder annotationBuilder = AnnotationSpec.builder(annotationName); Optional.ofNullable(model.getMembers()).map(Map::entrySet) .ifPresent(entries -> entries.forEach(entry -> annotationBuilder.addMember(entry.getKey(), entry.getValue()))); typeSpec.addAnnotation(annotationBuilder.build()); } } ClassAnnotationHandler(Tune tune, MetaInfo metaInfo, RuleSet ruleSet); @Override void process(TypeSpec.Builder typeSpec, TypeModel typeModel); }
ClassAnnotationHandler extends Handler { @Override public void process(TypeSpec.Builder typeSpec, TypeModel typeModel) { List<AnnotationModel> classAnnotations = consolidateClassAnnotations(tune, typeModel); for (AnnotationModel model : classAnnotations) { ClassName annotationName = getClassName(model.getClassName()); AnnotationSpec.Builder annotationBuilder = AnnotationSpec.builder(annotationName); Optional.ofNullable(model.getMembers()).map(Map::entrySet) .ifPresent(entries -> entries.forEach(entry -> annotationBuilder.addMember(entry.getKey(), entry.getValue()))); typeSpec.addAnnotation(annotationBuilder.build()); } } ClassAnnotationHandler(Tune tune, MetaInfo metaInfo, RuleSet ruleSet); @Override void process(TypeSpec.Builder typeSpec, TypeModel typeModel);  }