Sonar Fixes (#2232)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -16,7 +16,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@@ -87,6 +87,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
|
||||
private final DistributionSetInvalidationManagement distributionSetInvalidationManagement;
|
||||
private final TenantConfigHelper tenantConfigHelper;
|
||||
|
||||
@SuppressWarnings("java:S107")
|
||||
MgmtDistributionSetResource(
|
||||
final SoftwareModuleManagement softwareModuleManagement,
|
||||
final TargetManagement targetManagement, final TargetFilterQueryManagement targetFilterQueryManagement,
|
||||
|
||||
@@ -39,22 +39,19 @@ final class MgmtDistributionSetTypeMapper {
|
||||
|
||||
}
|
||||
|
||||
static List<DistributionSetTypeCreate> smFromRequest(final EntityFactory entityFactory,
|
||||
final Collection<MgmtDistributionSetTypeRequestBodyPost> smTypesRest) {
|
||||
static List<DistributionSetTypeCreate> smFromRequest(final EntityFactory entityFactory, final Collection<MgmtDistributionSetTypeRequestBodyPost> smTypesRest) {
|
||||
if (smTypesRest == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return smTypesRest.stream().map(smRest -> fromRequest(entityFactory, smRest)).collect(Collectors.toList());
|
||||
return smTypesRest.stream().map(smRest -> fromRequest(entityFactory, smRest)).toList();
|
||||
}
|
||||
|
||||
static List<MgmtDistributionSetType> toListResponse(final Collection<DistributionSetType> types) {
|
||||
if (types == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return new ResponseList<>(
|
||||
types.stream().map(MgmtDistributionSetTypeMapper::toResponse).collect(Collectors.toList()));
|
||||
return new ResponseList<>(types.stream().map(MgmtDistributionSetTypeMapper::toResponse).toList());
|
||||
}
|
||||
|
||||
static MgmtDistributionSetType toResponse(final DistributionSetType type) {
|
||||
@@ -82,19 +79,18 @@ final class MgmtDistributionSetTypeMapper {
|
||||
final MgmtDistributionSetTypeRequestBodyPost smsRest) {
|
||||
return entityFactory.distributionSetType().create().key(smsRest.getKey()).name(smsRest.getName())
|
||||
.description(smsRest.getDescription()).colour(smsRest.getColour())
|
||||
.mandatory(getMandatoryModules(smsRest)).optional(getOptionalmodules(smsRest));
|
||||
.mandatory(getMandatoryModules(smsRest)).optional(getOptionalModules(smsRest));
|
||||
}
|
||||
|
||||
private static Collection<Long> getMandatoryModules(final MgmtDistributionSetTypeRequestBodyPost smsRest) {
|
||||
return Optional.ofNullable(smsRest.getMandatorymodules()).map(
|
||||
modules -> modules.stream().map(MgmtSoftwareModuleTypeAssignment::getId).collect(Collectors.toList()))
|
||||
return Optional.ofNullable(smsRest.getMandatorymodules())
|
||||
.map(modules -> modules.stream().map(MgmtSoftwareModuleTypeAssignment::getId).toList())
|
||||
.orElse(Collections.emptyList());
|
||||
}
|
||||
|
||||
private static Collection<Long> getOptionalmodules(final MgmtDistributionSetTypeRequestBodyPost smsRest) {
|
||||
return Optional.ofNullable(smsRest.getOptionalmodules()).map(
|
||||
modules -> modules.stream().map(MgmtSoftwareModuleTypeAssignment::getId).collect(Collectors.toList()))
|
||||
private static Collection<Long> getOptionalModules(final MgmtDistributionSetTypeRequestBodyPost smsRest) {
|
||||
return Optional.ofNullable(smsRest.getOptionalmodules())
|
||||
.map(modules -> modules.stream().map(MgmtSoftwareModuleTypeAssignment::getId).toList())
|
||||
.orElse(Collections.emptyList());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user