Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Commit

Permalink
refactor: use Optional to handle non existing IDENTIFYING attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
flyisland committed Oct 26, 2021
1 parent 52ed45e commit e0ebd80
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/main/java/com/solace/tools/solconfig/model/ConfigObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,9 @@ private StringBuilder childrenToJsonString(int level) {
*/
public String getObjectId() {
var idList = sempSpec.getAttributeNames(AttributeType.IDENTIFYING).stream()
.map(id -> {
var idObj =attributes.get(id);
// Identifying attributes might not be required attributes, like "/msgVpns/bridges/remoteMsgVpns"
if (Objects.isNull(idObj)) {
return "";
} else {
return idObj.toString();
}
})
.map(s -> percentEncoding(s))
// Identifying attributes might not be required attributes, like "/msgVpns/bridges/remoteMsgVpns"
.map(id -> Optional.ofNullable(attributes.get(id)).orElse("").toString())
.map(ConfigObject::percentEncoding)
.collect(Collectors.toList());
return String.join(",", idList);
}
Expand Down

0 comments on commit e0ebd80

Please sign in to comment.