File tree 1 file changed +6
-3
lines changed
src/main/java/org/gridsuite/shortcircuit/server/repositories
1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 6
6
*/
7
7
package org .gridsuite .shortcircuit .server .repositories ;
8
8
9
- import lombok .NonNull ;
10
9
import org .gridsuite .shortcircuit .server .entities .ShortCircuitParametersEntity ;
11
10
import org .springframework .data .jpa .repository .JpaRepository ;
11
+ import org .springframework .lang .Nullable ;
12
12
import org .springframework .stereotype .Repository ;
13
13
14
+ import java .util .Optional ;
14
15
import java .util .UUID ;
15
16
16
17
@ Repository
17
18
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 ()));
20
23
}
21
24
}
You can’t perform that action at this time.
0 commit comments