Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
- Changing from comparing strings to comparing uuids in `EntitySource.findFirstEntityByUuid` [#829](https://github.com/ie3-institute/PowerSystemDataModel/issues/829)

- Adding JavaDoc to `EntitySource.safeMapGet` [#828](https://github.com/ie3-institute/PowerSystemDataModel/issues/828)

## [4.1.0] - 2023-11-02

Expand Down
13 changes: 12 additions & 1 deletion src/main/java/edu/ie3/datamodel/io/source/EntitySource.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ protected String buildSkippingMessage(
+ missingElementsString;
}

/**
* Method for retrieving an element from a map. If the map doesn't contain the key an error
* message is build and returned instead.
*
* <p>Should not be used for other purposes than creating error messages.
*
* @param map with value
* @param key for the value
* @param mapName name of the map used for the error message
* @return either the value or an error message
*/
protected String safeMapGet(Map<String, String> map, String key, String mapName) {
return Optional.ofNullable(map.get(key))
.orElse(
Expand Down Expand Up @@ -83,7 +94,7 @@ protected <T extends UniqueEntity> Optional<T> findFirstEntityByUuid(
* the provided fields to values mapping. The provided fields to values mapping needs to have one
* and only one field with key {@link #TYPE} and a corresponding UUID value. If the type can be
* found in the provided collection based on the UUID it is returned wrapped in a {@link Success}.
* Otherwise a {@link Failure} is returned and a warning is logged.
* Otherwise, a {@link Failure} is returned and a warning is logged.
*
* @param types a collection of types that should be used for searching
* @param fieldsToAttributes the field name to value mapping incl. the key {@link #TYPE}
Expand Down