11
11
import jakarta .persistence .*;
12
12
import lombok .*;
13
13
import org .gridsuite .shortcircuit .server .dto .ShortCircuitPredefinedConfiguration ;
14
+ import org .jetbrains .annotations .Nullable ;
14
15
15
16
import java .util .UUID ;
16
17
@@ -34,18 +35,8 @@ public ShortCircuitParametersEntity(boolean withLimitViolations, boolean withVol
34
35
}
35
36
36
37
public ShortCircuitParametersEntity (ShortCircuitParametersEntity entity ) {
37
- this (entity .withLimitViolations ,
38
- entity .withVoltageResult ,
39
- entity .withFortescueResult ,
40
- entity .withFeederResult ,
41
- entity .studyType ,
42
- entity .minVoltageDropProportionalThreshold ,
43
- entity .predefinedParameters ,
44
- entity .withLoads ,
45
- entity .withShuntCompensators ,
46
- entity .withVscConverterStations ,
47
- entity .withNeutralPosition ,
48
- entity .initialVoltageProfileMode );
38
+ this ();
39
+ this .updateFrom (entity );
49
40
}
50
41
51
42
@ Id
@@ -91,4 +82,38 @@ public ShortCircuitParametersEntity(ShortCircuitParametersEntity entity) {
91
82
@ Column (name = "initialVoltageProfileMode" , columnDefinition = "varchar(15) default \" NOMINAL\" " )
92
83
@ Enumerated (EnumType .STRING )
93
84
private InitialVoltageProfileMode initialVoltageProfileMode = InitialVoltageProfileMode .NOMINAL ;
85
+
86
+ /**
87
+ * Reset values to defaults ones
88
+ * @return this instance
89
+ */
90
+ public ShortCircuitParametersEntity resetToDefaults () {
91
+ this .updateFrom (new ShortCircuitParametersEntity ());
92
+ return this ;
93
+ }
94
+
95
+ /**
96
+ * Update an entity using values of another one
97
+ * @param entity the entity to take values from, will reset if {@code null}
98
+ * @return this instance
99
+ */
100
+ public ShortCircuitParametersEntity updateFrom (@ Nullable final ShortCircuitParametersEntity entity ) {
101
+ if (entity == null ) {
102
+ this .resetToDefaults ();
103
+ } else {
104
+ this .setWithLimitViolations (entity .withLimitViolations );
105
+ this .setWithVoltageResult (entity .withVoltageResult );
106
+ this .setWithFortescueResult (entity .withFortescueResult );
107
+ this .setWithFeederResult (entity .withFeederResult );
108
+ this .setStudyType (entity .studyType );
109
+ this .setMinVoltageDropProportionalThreshold (entity .minVoltageDropProportionalThreshold );
110
+ this .setPredefinedParameters (entity .predefinedParameters );
111
+ this .setWithLoads (entity .withLoads );
112
+ this .setWithShuntCompensators (entity .withShuntCompensators );
113
+ this .setWithVscConverterStations (entity .withVscConverterStations );
114
+ this .setWithNeutralPosition (entity .withNeutralPosition );
115
+ this .setInitialVoltageProfileMode (entity .initialVoltageProfileMode );
116
+ }
117
+ return this ;
118
+ }
94
119
}
0 commit comments