Commit 1daa1454 authored by Daniel Bluhm's avatar Daniel Bluhm

Drop previous writer generation method

Signed-off-by: Daniel Bluhm's avatarDaniel Bluhm <bluhmdj@ornl.gov>
parent c766cc9d
......@@ -77,11 +77,11 @@ public class DataElementAnnotationExtractor {
* @return list of generated SourceWriters
* @throws IOException due to {@link ICEAnnotationExtractionService#extract(AnnotationExtractionRequest)}
*/
public List<SelfInitializingWriter> generateWriters(
public List<GeneratedFileWriter> generateWriters(
AnnotationExtractionRequest request
) throws IOException {
AnnotationExtractionResponse response = annotationExtractionService.extract(request);
return writerGenerator.generateWriters(request.getElement(),response);
return writerGenerator.generate(response);
}
/**
......@@ -91,17 +91,8 @@ public class DataElementAnnotationExtractor {
* @throws IOException
*/
public void generateAndWrite(AnnotationExtractionRequest request) throws IOException {
AnnotationExtractionResponse response = annotationExtractionService.extract(request);
Filer filer = writerGenerator.processingEnv.getFiler();
writerGenerator.generateWriters(request.getElement(),response)
.forEach(writer -> {
try {
writer.write();
} catch (IOException e) {
e.printStackTrace();
}
});
writerGenerator.generate(response)
generateWriters(request)
.forEach(writer -> {
try (Writer file = writer.openWriter(filer)) {
writer.write(file);
......
......@@ -50,37 +50,6 @@ public class DataElementWriterGenerator
super(processingEnv);
}
/**
* DataElement specific method of class generation. Includes interfaces,
* implementation, and possibly a persistence handler
*/
public List<SelfInitializingWriter> generateWriters(
Element element, AnnotationExtractionResponse response
) {
List<SelfInitializingWriter> writers = new ArrayList<>();
Map<TemplateProperty, Object> classMetadata = response.getClassMetadata();
boolean hasAnnotation = specExtractionHelper.hasAnnotation(element, Persisted.class);
writerInitializers.keySet().stream()
.filter(key -> key != PersistenceHandlerTemplateProperty.QUALIFIED || hasAnnotation)
.forEach(key -> {
try {
String name = (String) classMetadata.get(key);
FileObject fileObject = createFileObjectForName(name);
List<SelfInitializingWriter> newWriters = writerInitializers
.get(key)
.apply(
fileObject,
classMetadata
);
writers.addAll(newWriters);
} catch (UnsupportedOperationException | IOException e) {
e.printStackTrace();
}
});
return writers;
}
@Override
public List<GeneratedFileWriter> generate(AnnotationExtractionResponse response) {
List<GeneratedFileWriter> writers = new ArrayList<>();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment