Skip to content

Commit

Permalink
Apply review suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Wouter Born <github@maindrain.net>
  • Loading branch information
wborn committed Jan 3, 2024
1 parent b6b1cee commit c0a75e8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ protected List<String> getPreviousPortfolio(Vendor vendor) {
if (portfolio == null) {
for (Entry<Vendor, List<String>> entry : providerPortfolio.entrySet()) {
if (entry.getKey().getVendorSymbolicName().equals(vendor.getVendorSymbolicName())) {
List<String> vendorPortfolio = entry.getValue();
return vendorPortfolio == null ? List.of() : vendorPortfolio;
return entry.getValue();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,33 +105,30 @@ public void validate(Map<String, Object> configurationParameters, URI configDesc
for (Entry<String, ConfigDescriptionParameter> entry : map.entrySet()) {
String key = entry.getKey();
ConfigDescriptionParameter configDescriptionParameter = entry.getValue();
if (configDescriptionParameter != null) {
// If the parameter supports multiple selection, then it may be provided as an array
if (configDescriptionParameter.isMultiple() && configurationParameters.get(key) instanceof List) {
List<Object> values = (List<Object>) configurationParameters.get(key);
// check if multipleLimit is obeyed
Integer multipleLimit = configDescriptionParameter.getMultipleLimit();
if (multipleLimit != null && values.size() > multipleLimit) {
MessageKey messageKey = MessageKey.MULTIPLE_LIMIT_VIOLATED;
ConfigValidationMessage message = new ConfigValidationMessage(
configDescriptionParameter.getName(), messageKey.defaultMessage, messageKey.key,
multipleLimit, values.size());
configDescriptionValidationMessages.add(message);
}
// Perform validation on each value in the list separately
for (Object value : values) {
ConfigValidationMessage message = validateParameter(configDescriptionParameter, value);
if (message != null) {
configDescriptionValidationMessages.add(message);
}
}
} else {
ConfigValidationMessage message = validateParameter(configDescriptionParameter,
configurationParameters.get(key));
// If the parameter supports multiple selection, then it may be provided as an array
if (configDescriptionParameter.isMultiple() && configurationParameters.get(key) instanceof List) {
List<Object> values = (List<Object>) configurationParameters.get(key);
// check if multipleLimit is obeyed
Integer multipleLimit = configDescriptionParameter.getMultipleLimit();
if (multipleLimit != null && values.size() > multipleLimit) {
MessageKey messageKey = MessageKey.MULTIPLE_LIMIT_VIOLATED;
ConfigValidationMessage message = new ConfigValidationMessage(configDescriptionParameter.getName(),
messageKey.defaultMessage, messageKey.key, multipleLimit, values.size());
configDescriptionValidationMessages.add(message);
}
// Perform validation on each value in the list separately
for (Object value : values) {
ConfigValidationMessage message = validateParameter(configDescriptionParameter, value);
if (message != null) {
configDescriptionValidationMessages.add(message);
}
}
} else {
ConfigValidationMessage message = validateParameter(configDescriptionParameter,
configurationParameters.get(key));
if (message != null) {
configDescriptionValidationMessages.add(message);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,11 @@ protected void eventReceived(GENASubscription sub) {
for (UpnpIOParticipant participant : participants) {
if (Objects.equals(getDevice(participant), deviceRoot)) {
for (Entry<String, StateVariableValue> entry : values.entrySet()) {
StateVariableValue value = entry.getValue();
if (value.getValue() != null) {
try {
participant.onValueReceived(entry.getKey(), value.getValue().toString(), serviceId);
} catch (Exception e) {
logger.error("Participant threw an exception onValueReceived", e);
}
try {
participant.onValueReceived(entry.getKey(), entry.getValue().getValue().toString(),
serviceId);
} catch (Exception e) {
logger.error("Participant threw an exception onValueReceived", e);
}
}
break;
Expand Down

0 comments on commit c0a75e8

Please sign in to comment.