Skip to content

Commit e12fd7d

Browse files
error found & fix
1 parent 2284791 commit e12fd7d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/main/java/org/gridsuite/shortcircuit/server/repositories/ParametersRepository.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@
66
*/
77
package org.gridsuite.shortcircuit.server.repositories;
88

9-
import lombok.NonNull;
109
import org.gridsuite.shortcircuit.server.entities.ShortCircuitParametersEntity;
1110
import org.springframework.data.jpa.repository.JpaRepository;
11+
import org.springframework.lang.Nullable;
1212
import org.springframework.stereotype.Repository;
1313

14+
import java.util.Optional;
1415
import java.util.UUID;
1516

1617
@Repository
1718
public interface ParametersRepository extends JpaRepository<ShortCircuitParametersEntity, UUID> {
18-
default ShortCircuitParametersEntity getByIdOrDefault(@NonNull final UUID id) {
19-
return findById(id).orElseGet(() -> this.save(new ShortCircuitParametersEntity()));
19+
default ShortCircuitParametersEntity getByIdOrDefault(@Nullable final UUID id) {
20+
return Optional.ofNullable(id)
21+
.flatMap(this::findById)
22+
.orElseGet(() -> this.save(new ShortCircuitParametersEntity()));
2023
}
2124
}

0 commit comments

Comments
 (0)