Commit bdb24a43 authored by Daniel Bluhm's avatar Daniel Bluhm

Use intermediate values instead of direct returns

According to PR feedback. This will improve debugging.
Note: Sonar Lint is not fond of this practice but better experience
while debugging is favorable to this particular Sonar Lint rule.
Signed-off-by: Daniel Bluhm's avatarDaniel Bluhm <bluhmdj@ornl.gov>
parent 16e61698
......@@ -85,11 +85,12 @@ public class DataElementExtractor
fields.collect(DefaultFields.get());
fields.collect(extractFields(element));
return DataElementMetadata.builder()
DataElementMetadata data = DataElementMetadata.builder()
.name(extractName(helper))
.packageName(extractPackageName(element))
.fields(fields)
.build();
return data;
}
/**
......
......@@ -69,7 +69,7 @@ public class DataFieldExtractor implements AnnotationExtractor<Field> {
"DataField annotation not found on element."
);
}
return Field.builder()
Field field = Field.builder()
.name(extractFieldName(element))
.type(extractFieldType(element))
.defaultValue(extractDefaultValue(element))
......@@ -83,6 +83,7 @@ public class DataFieldExtractor implements AnnotationExtractor<Field> {
.searchable(fieldInfo.searchable())
.nullable(fieldInfo.nullable())
.build();
return field;
}
/**
......
......@@ -34,7 +34,7 @@ public class PersistenceWriterGenerator implements WriterGenerator {
@Override
public List<GeneratedFileWriter> generate() {
return List.of(
List<GeneratedFileWriter> writers = List.of(
PersistenceHandlerWriter.builder()
.packageName(dataElement.getPackageName())
.elementInterface(dataElement.getName())
......@@ -47,6 +47,6 @@ public class PersistenceWriterGenerator implements WriterGenerator {
.types(dataElement.getFields().getTypes())
.build()
);
return writers;
}
}
}
\ No newline at end of file
......@@ -37,7 +37,7 @@ public class WriterGeneratorFactory {
/**
* Generators to potentially create.
*/
private Set<Class<? extends WriterGenerator>> generators;
private Set<Class<? extends WriterGenerator>> generatorClasses;
/**
* Create WriterGeneratorFactory.
......@@ -46,7 +46,7 @@ public class WriterGeneratorFactory {
public WriterGeneratorFactory(
Set<Class<? extends WriterGenerator>> generators
) {
this.generators = generators;
this.generatorClasses = generators;
}
/**
......@@ -56,11 +56,12 @@ public class WriterGeneratorFactory {
* @return created writer generators.
*/
public Set<WriterGenerator> create(Map<Class<?>, Object> dataPool) {
return generators.stream()
Set<WriterGenerator> generators = generatorClasses.stream()
.map(cls -> create(cls, dataPool))
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toSet());
return generators;
}
/**
......
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