Skip to content

Commit

Permalink
Update switch to if else
Browse files Browse the repository at this point in the history
  • Loading branch information
loicgreffier committed Nov 18, 2023
1 parent bd7018c commit 38f2585
Showing 1 changed file with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.michelin.suricate.model.entities.Widget;
import com.michelin.suricate.model.entities.WidgetParam;
import com.michelin.suricate.model.entities.WidgetParamValue;
import com.michelin.suricate.model.enums.DataTypeEnum;
import com.michelin.suricate.model.enums.WidgetAvailabilityEnum;
import com.michelin.suricate.repositories.WidgetParamRepository;
import com.michelin.suricate.repositories.WidgetRepository;
Expand Down Expand Up @@ -144,17 +145,12 @@ public List<WidgetVariableResponseDto> getWidgetParametersForJsExecution(final W
widgetVariableResponseDto.setType(widgetParameter.getType());
widgetVariableResponseDto.setDefaultValue(widgetParameter.getDefaultValue());

if (widgetVariableResponseDto.getType() != null) {
switch (widgetVariableResponseDto.getType()) {
case COMBO, MULTIPLE:
widgetVariableResponseDto.setValues(
getWidgetParamValuesAsMap(widgetParameter.getPossibleValuesMap()));
break;

default:
widgetVariableResponseDto.setData(StringUtils.trimToNull(widgetParameter.getDefaultValue()));
break;
}
if (widgetVariableResponseDto.getType() == DataTypeEnum.COMBO
|| widgetVariableResponseDto.getType() == DataTypeEnum.MULTIPLE) {
widgetVariableResponseDto.setValues(
getWidgetParamValuesAsMap(widgetParameter.getPossibleValuesMap()));
} else {
widgetVariableResponseDto.setData(StringUtils.trimToNull(widgetParameter.getDefaultValue()));
}

widgetVariableResponseDtos.add(widgetVariableResponseDto);
Expand Down

0 comments on commit 38f2585

Please sign in to comment.