class FirmwareManagementService extends AbstractService {

    public List<FirmwareVersion> checkFirmwareHistoryForVersion(final String deviceId,
            final List<FirmwareVersion> firmwareVersions) {

        if (firmwareVersions.isEmpty()) {
            return firmwareVersions;
        }
        // copy input parameter
        final List<FirmwareVersion> firmwareVersionsToCheck = new ArrayList<>(firmwareVersions);

        // get history
        final Device device = this.deviceRepository.findByDeviceIdentification(deviceId);
        final List<DeviceFirmwareFile> deviceFirmwareFiles = this.deviceFirmwareFileRepository
                .findByDeviceOrderByInstallationDateAsc(device);
        final List<FirmwareVersion> firmwareVersionsInHistory = deviceFirmwareFiles.stream()
                .map(d -> d.getFirmwareFile().getModuleVersions().entrySet())
                .flatMap(Collection::stream)
                .map(e -> new FirmwareVersion(FirmwareModuleType.forDescription(e.getKey().getDescription()),
                        e.getValue()))
                .collect(Collectors.toList());

        // remove the history versions
        firmwareVersionsToCheck.removeAll(firmwareVersionsInHistory);

        return firmwareVersionsToCheck;
    }

    public  FirmwareManagementService();

}