Sonar Fixes (7) (#2216)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-01-21 22:13:54 +02:00
committed by GitHub
parent f09db20b71
commit 3d390b9ad7
21 changed files with 101 additions and 101 deletions

View File

@@ -12,7 +12,6 @@ package org.eclipse.hawkbit.mgmt.rest.resource;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
@@ -41,7 +40,7 @@ public final class MgmtActionMapper {
}
return new ResponseList<>(actions.stream()
.map(action -> toResponse(action, repMode))
.collect(Collectors.toList()));
.toList());
}
static MgmtAction toResponse(final Action action, final MgmtRepresentationMode repMode) {

View File

@@ -51,7 +51,7 @@ public final class MgmtDistributionSetMapper {
*/
static List<DistributionSetCreate> dsFromRequest(
final Collection<MgmtDistributionSetRequestBodyPost> sets, final EntityFactory entityFactory) {
return sets.stream().map(dsRest -> fromRequest(dsRest, entityFactory)).collect(Collectors.toList());
return sets.stream().map(dsRest -> fromRequest(dsRest, entityFactory)).toList();
}
static List<MetaData> fromRequestDsMetadata(final List<MgmtMetadata> metadata, final EntityFactory entityFactory) {
@@ -61,7 +61,7 @@ public final class MgmtDistributionSetMapper {
return metadata.stream()
.map(metadataRest -> entityFactory.generateDsMetadata(metadataRest.getKey(), metadataRest.getValue()))
.collect(Collectors.toList());
.toList();
}
static MgmtDistributionSet toResponse(final DistributionSet distributionSet) {
@@ -111,7 +111,7 @@ public final class MgmtDistributionSetMapper {
final MgmtTargetAssignmentResponseBody result = new MgmtTargetAssignmentResponseBody();
result.setAlreadyAssigned(dsAssignmentResult.getAlreadyAssigned());
result.setAssignedActions(dsAssignmentResult.getAssignedEntity().stream()
.map(a -> new MgmtActionId(a.getTarget().getControllerId(), a.getId())).collect(Collectors.toList()));
.map(a -> new MgmtActionId(a.getTarget().getControllerId(), a.getId())).toList());
return result;
}
@@ -123,7 +123,7 @@ public final class MgmtDistributionSetMapper {
final List<MgmtActionId> assignedActions = dsAssignmentResults.stream()
.flatMap(assignmentResult -> assignmentResult.getAssignedEntity().stream())
.map(action -> new MgmtActionId(action.getTarget().getControllerId(), action.getId()))
.collect(Collectors.toList());
.toList();
result.setAlreadyAssigned(alreadyAssigned);
result.setAssignedActions(assignedActions);
return result;
@@ -136,7 +136,7 @@ public final class MgmtDistributionSetMapper {
}
return new ResponseList<>(
sets.stream().map(MgmtDistributionSetMapper::toResponse).collect(Collectors.toList()));
sets.stream().map(MgmtDistributionSetMapper::toResponse).toList());
}
static MgmtMetadata toResponseDsMetadata(final DistributionSetMetadata metadata) {
@@ -159,7 +159,7 @@ public final class MgmtDistributionSetMapper {
return Collections.emptyList();
}
return sets.stream().map(MgmtDistributionSetMapper::toResponse).collect(Collectors.toList());
return sets.stream().map(MgmtDistributionSetMapper::toResponse).toList();
}
/**

View File

@@ -268,10 +268,9 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
: dsAssignment.getConfirmationRequired();
return MgmtDeploymentRequestMapper.createAssignmentRequestBuilder(dsAssignment, distributionSetId)
.setConfirmationRequired(isConfirmationRequired).build();
}).collect(Collectors.toList());
}).toList();
final List<DistributionSetAssignmentResult> assignmentResults = deployManagement
.assignDistributionSets(deploymentRequests);
final List<DistributionSetAssignmentResult> assignmentResults = deployManagement.assignDistributionSets(deploymentRequests);
return ResponseEntity.ok(MgmtDistributionSetMapper.toResponse(assignmentResults));
}
@@ -338,7 +337,7 @@ public class MgmtDistributionSetResource implements MgmtDistributionSetRestApi {
distributionSetId,
softwareModuleIDs.stream()
.map(MgmtSoftwareModuleAssignment::getId)
.collect(Collectors.toList()));
.toList());
return ResponseEntity.ok().build();
}