class FunctionalityService {

    public void delete(Long projectId, Long id) throws BadRequestException {
        if (id == null) {
            throw new BadRequestException(Messages.PARAMETER_IS_MISSING, Entities.FUNCTIONALITY, "delete_functionality_missing_id_parameter");
        }
        Functionality entity = repository.findByProjectIdAndId(projectId, id)
                .orElseThrow(() -> new NotFoundException(Messages.NOT_FOUND_FUNCTIONALITY_OR_FOLDER, Entities.FUNCTIONALITY));
        // Will cascade delete children
        repository.delete(entity);
    }

}