Skip to content

Commit fda8e99

Browse files
committed
minor changes + fmt
1 parent c3ad436 commit fda8e99

File tree

10 files changed

+35
-64
lines changed

10 files changed

+35
-64
lines changed

src/main/java/edu/ie3/datamodel/io/connectors/CsvFileConnector.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public BufferedReader initReader(Class<? extends UniqueEntity> clz) throws FileN
159159
+ "'."));
160160
} catch (ConnectorException e) {
161161
log.error(
162-
"Cannot get reader for entity '{}' as no file naming strategy for this file exists. Exception:{}",
162+
"Cannot get reader for entity '{}' as no file naming strategy for this file exists. Exception: {}",
163163
clz::getSimpleName,
164164
() -> e);
165165
}
@@ -204,8 +204,7 @@ public Optional<IndividualTimeSeriesMetaInformation> getIndividualTimeSeriesMeta
204204
*/
205205
private Map<UUID, CsvIndividualTimeSeriesMetaInformation>
206206
buildIndividualTimeSeriesMetaInformation() {
207-
return getIndividualTimeSeriesFilePaths()
208-
.parallelStream()
207+
return getIndividualTimeSeriesFilePaths().parallelStream()
209208
.map(
210209
filePath -> {
211210
/* Extract meta information from file path and enhance it with the file path itself */
@@ -233,8 +232,7 @@ public Optional<IndividualTimeSeriesMetaInformation> getIndividualTimeSeriesMeta
233232
@Deprecated
234233
public Map<ColumnScheme, Set<TimeSeriesReadingData>> initTimeSeriesReader(
235234
ColumnScheme... columnSchemes) {
236-
return getIndividualTimeSeriesFilePaths()
237-
.parallelStream()
235+
return getIndividualTimeSeriesFilePaths().parallelStream()
238236
.map(
239237
pathString -> {
240238
String filePathWithoutEnding = removeFileEnding(pathString);

src/main/java/edu/ie3/datamodel/io/processor/timeseries/TimeSeriesProcessor.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public TimeSeriesProcessor(Class<T> timeSeriesClass, Class<E> entryClass, Class<
7777
if (!eligibleKeys.contains(timeSeriesKey))
7878
throw new EntityProcessorException(
7979
"Cannot register time series combination '"
80-
+ timeSeriesKey.toString()
80+
+ timeSeriesKey
8181
+ "' with entity processor '"
8282
+ this.getClass().getSimpleName()
8383
+ "'. Eligible combinations: "
@@ -106,7 +106,8 @@ private SortedMap<String, FieldSourceToMethod> buildFieldToSource(
106106
Class<T> timeSeriesClass, Class<E> entryClass, Class<V> valueClass) {
107107
/* Get the mapping from field name to getter method ignoring the getter for returning all entries */
108108
Map<String, FieldSourceToMethod> timeSeriesMapping =
109-
mapFieldNameToGetter(timeSeriesClass, Arrays.asList("entries", "uuid", "type")).entrySet()
109+
mapFieldNameToGetter(timeSeriesClass, Arrays.asList("entries", "uuid", "type"))
110+
.entrySet()
110111
.stream()
111112
.collect(
112113
Collectors.toMap(
@@ -136,7 +137,8 @@ private SortedMap<String, FieldSourceToMethod> buildFieldToSource(
136137
mapFieldNameToGetter(
137138
valueClass,
138139
Arrays.asList("solarIrradiance", "temperature", "wind"))
139-
.entrySet().stream()
140+
.entrySet()
141+
.stream()
140142
.map(
141143
entry ->
142144
new AbstractMap.SimpleEntry<>(

src/main/java/edu/ie3/datamodel/io/source/csv/CsvDataSource.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -356,18 +356,12 @@ protected <T extends UniqueEntity> Optional<T> findFirstEntityByUuid(
356356
*/
357357
protected Stream<Map<String, String>> buildStreamWithFieldsToAttributesMap(
358358
Class<? extends UniqueEntity> entityClass, CsvFileConnector connector) {
359-
try (BufferedReader reader = connector.initReader(entityClass)) {
360-
return buildStreamWithFieldsToAttributesMap(entityClass, reader);
359+
try {
360+
return buildStreamWithFieldsToAttributesMap(entityClass, connector.initReader(entityClass));
361361
} catch (FileNotFoundException e) {
362362
log.warn(
363363
"Unable to find file for entity '{}': {}", entityClass.getSimpleName(), e.getMessage());
364-
} catch (IOException e) {
365-
log.warn(
366-
"Unable to close stream from file for entity '{}': {}",
367-
entityClass.getSimpleName(),
368-
e.getMessage());
369364
}
370-
371365
return Stream.empty();
372366
}
373367

@@ -400,10 +394,7 @@ protected Stream<Map<String, String>> buildStreamWithFieldsToAttributesMap(
400394
Collection<Map<String, String>> allRows = csvRowFieldValueMapping(reader, headline);
401395

402396
return distinctRowsWithLog(
403-
allRows,
404-
fieldToValues -> fieldToValues.get("uuid"),
405-
entityClass.getSimpleName(),
406-
"UUID")
397+
allRows, fieldToValues -> fieldToValues.get("uuid"), entityClass.getSimpleName(), "UUID")
407398
.parallelStream();
408399
} catch (IOException e) {
409400
log.warn(
@@ -462,8 +453,7 @@ protected Set<Map<String, String>> distinctRowsWithLog(
462453

463454
/* Check for rows with the same key based on the provided key extractor function */
464455
Set<Map<String, String>> distinctIdSet =
465-
allRowsSet
466-
.parallelStream()
456+
allRowsSet.parallelStream()
467457
.filter(ValidationUtils.distinctByKey(keyExtractor))
468458
.collect(Collectors.toSet());
469459
if (distinctIdSet.size() != allRowsSet.size()) {

src/main/java/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ protected Stream<Map<String, String>> buildStreamWithFieldsToAttributesMap() {
123123
.get(factory.getLatField())
124124
.concat(fieldToValues.get(factory.getLonField()));
125125
return distinctRowsWithLog(
126-
withDistinctCoordinateId, coordinateExtractor, "coordinate id mapping", "coordinate")
126+
withDistinctCoordinateId, coordinateExtractor, "coordinate id mapping", "coordinate")
127127
.parallelStream();
128128
} catch (IOException e) {
129129
log.error("Cannot read the file for coordinate id to coordinate mapping.", e);

src/main/java/edu/ie3/datamodel/io/source/csv/CsvWeatherSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ protected Stream<Map<String, String>> buildStreamWithFieldsToAttributesMap(
246246
.get(weatherFactory.getTimeFieldString())
247247
.concat(fieldToValues.get(weatherFactory.getCoordinateIdFieldString()));
248248
return distinctRowsWithLog(
249-
allRows, timeCoordinateIdExtractor, entityClass.getSimpleName(), "UUID")
249+
allRows, timeCoordinateIdExtractor, entityClass.getSimpleName(), "UUID")
250250
.parallelStream();
251251

252252
} catch (IOException e) {

src/main/java/edu/ie3/datamodel/models/input/container/GraphicElements.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,12 @@ public GraphicElements(List<GraphicInput> graphics) {
4848

4949
/* init sets */
5050
this.nodeGraphics =
51-
graphics
52-
.parallelStream()
51+
graphics.parallelStream()
5352
.filter(graphic -> graphic instanceof NodeGraphicInput)
5453
.map(graphic -> (NodeGraphicInput) graphic)
5554
.collect(Collectors.toSet());
5655
this.lineGraphics =
57-
graphics
58-
.parallelStream()
56+
graphics.parallelStream()
5957
.filter(graphic -> graphic instanceof LineGraphicInput)
6058
.map(graphic -> (LineGraphicInput) graphic)
6159
.collect(Collectors.toSet());

src/main/java/edu/ie3/datamodel/models/input/container/RawGridElements.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,38 +84,32 @@ public RawGridElements(List<AssetInput> rawGridElements) {
8484

8585
/* init sets */
8686
this.nodes =
87-
rawGridElements
88-
.parallelStream()
87+
rawGridElements.parallelStream()
8988
.filter(gridElement -> gridElement instanceof NodeInput)
9089
.map(nodeInput -> (NodeInput) nodeInput)
9190
.collect(Collectors.toSet());
9291
this.lines =
93-
rawGridElements
94-
.parallelStream()
92+
rawGridElements.parallelStream()
9593
.filter(gridElement -> gridElement instanceof LineInput)
9694
.map(lineInput -> (LineInput) lineInput)
9795
.collect(Collectors.toSet());
9896
this.transformer2Ws =
99-
rawGridElements
100-
.parallelStream()
97+
rawGridElements.parallelStream()
10198
.filter(gridElement -> gridElement instanceof Transformer2WInput)
10299
.map(trafo2wInput -> (Transformer2WInput) trafo2wInput)
103100
.collect(Collectors.toSet());
104101
this.transformer3Ws =
105-
rawGridElements
106-
.parallelStream()
102+
rawGridElements.parallelStream()
107103
.filter(gridElement -> gridElement instanceof Transformer3WInput)
108104
.map(trafo3wInput -> (Transformer3WInput) trafo3wInput)
109105
.collect(Collectors.toSet());
110106
this.switches =
111-
rawGridElements
112-
.parallelStream()
107+
rawGridElements.parallelStream()
113108
.filter(gridElement -> gridElement instanceof SwitchInput)
114109
.map(switchInput -> (SwitchInput) switchInput)
115110
.collect(Collectors.toSet());
116111
this.measurementUnits =
117-
rawGridElements
118-
.parallelStream()
112+
rawGridElements.parallelStream()
119113
.filter(gridElement -> gridElement instanceof MeasurementUnitInput)
120114
.map(measurementUnitInput -> (MeasurementUnitInput) measurementUnitInput)
121115
.collect(Collectors.toSet());

src/main/java/edu/ie3/datamodel/models/input/container/SystemParticipants.java

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -106,62 +106,52 @@ public SystemParticipants(List<SystemParticipantInput> systemParticipants) {
106106

107107
/* init sets */
108108
this.bmPlants =
109-
systemParticipants
110-
.parallelStream()
109+
systemParticipants.parallelStream()
111110
.filter(gridElement -> gridElement instanceof BmInput)
112111
.map(bmInput -> (BmInput) bmInput)
113112
.collect(Collectors.toSet());
114113
this.chpPlants =
115-
systemParticipants
116-
.parallelStream()
114+
systemParticipants.parallelStream()
117115
.filter(gridElement -> gridElement instanceof ChpInput)
118116
.map(chpInput -> (ChpInput) chpInput)
119117
.collect(Collectors.toSet());
120118
this.evCS =
121-
systemParticipants
122-
.parallelStream()
119+
systemParticipants.parallelStream()
123120
.filter(gridElement -> gridElement instanceof EvcsInput)
124121
.map(evcsInput -> (EvcsInput) evcsInput)
125122
.collect(Collectors.toSet());
126123
this.evs =
127-
systemParticipants
128-
.parallelStream()
124+
systemParticipants.parallelStream()
129125
.filter(gridElement -> gridElement instanceof EvInput)
130126
.map(evInput -> (EvInput) evInput)
131127
.collect(Collectors.toSet());
132128
this.fixedFeedIns =
133-
systemParticipants
134-
.parallelStream()
129+
systemParticipants.parallelStream()
135130
.filter(gridElement -> gridElement instanceof FixedFeedInInput)
136131
.map(fixedFeedInInpu -> (FixedFeedInInput) fixedFeedInInpu)
137132
.collect(Collectors.toSet());
138133
this.heatPumps =
139-
systemParticipants
140-
.parallelStream()
134+
systemParticipants.parallelStream()
141135
.filter(gridElement -> gridElement instanceof HpInput)
142136
.map(hpInput -> (HpInput) hpInput)
143137
.collect(Collectors.toSet());
144138
this.loads =
145-
systemParticipants
146-
.parallelStream()
139+
systemParticipants.parallelStream()
147140
.filter(gridElement -> gridElement instanceof LoadInput)
148141
.map(loadInput -> (LoadInput) loadInput)
149142
.collect(Collectors.toSet());
150143
this.pvPlants =
151-
systemParticipants
152-
.parallelStream()
144+
systemParticipants.parallelStream()
153145
.filter(gridElement -> gridElement instanceof PvInput)
154146
.map(pvInput -> (PvInput) pvInput)
155147
.collect(Collectors.toSet());
156148
this.storages =
157-
systemParticipants
158-
.parallelStream()
149+
systemParticipants.parallelStream()
159150
.filter(gridElement -> gridElement instanceof StorageInput)
160151
.map(storageInput -> (StorageInput) storageInput)
161152
.collect(Collectors.toSet());
162153
this.wecPlants =
163-
systemParticipants
164-
.parallelStream()
154+
systemParticipants.parallelStream()
165155
.filter(gridElement -> gridElement instanceof WecInput)
166156
.map(wecInput -> (WecInput) wecInput)
167157
.collect(Collectors.toSet());

src/main/java/edu/ie3/datamodel/models/input/system/type/chargingpoint/ChargingPointTypeUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ private ChargingPointTypeUtils() {
142142
Stream.concat(
143143
Stream.of(type.getId().toLowerCase()),
144144
type.getSynonymousIds().stream().map(String::toLowerCase))
145-
.collect(Collectors.toMap(Function.identity(), v -> type)).entrySet()
145+
.collect(Collectors.toMap(Function.identity(), v -> type))
146+
.entrySet()
146147
.stream())
147148
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));
148149

src/main/java/edu/ie3/datamodel/utils/ContainerNodeUpdateUtil.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,7 @@ private static SystemParticipants updateSystemParticipantsWithNodes(
207207
SystemParticipants systemParticipants, Map<NodeInput, NodeInput> oldToNewNodes) {
208208

209209
List<SystemParticipantInput> sysParts =
210-
systemParticipants
211-
.allEntitiesAsList()
212-
.parallelStream()
210+
systemParticipants.allEntitiesAsList().parallelStream()
213211
.map(
214212
sysPart -> {
215213
if (oldToNewNodes.containsKey(sysPart.getNode())) {

0 commit comments

Comments
 (0)