@@ -45,29 +45,29 @@ public VoltageInitResultContext(UUID resultUuid, VoltageInitRunContext runContex
45
45
}
46
46
47
47
private static String getNonNullHeader (MessageHeaders headers , String name ) {
48
- String header = ( String ) headers .get (name );
48
+ final String header = headers .get (name , String . class );
49
49
if (header == null ) {
50
50
throw new PowsyblException ("Header '" + name + "' not found" );
51
+ } else {
52
+ return header ;
51
53
}
52
- return header ;
53
54
}
54
55
55
56
public static VoltageInitResultContext fromMessage (Message <String > message ) {
56
57
Objects .requireNonNull (message );
57
58
MessageHeaders headers = message .getHeaders ();
58
59
UUID resultUuid = UUID .fromString (getNonNullHeader (headers , "resultUuid" ));
59
60
UUID networkUuid = UUID .fromString (getNonNullHeader (headers , "networkUuid" ));
60
- String variantId = (String ) headers .get (VARIANT_ID_HEADER );
61
- String receiver = (String ) headers .get (HEADER_RECEIVER );
62
- String userId = (String ) headers .get (HEADER_USER_ID );
63
- Map <String , Double > voltageLevelsIdsRestricted = (Map <String , Double >) headers .get (VOLTAGE_LEVELS_IDS_RESTRICTED );
64
-
65
- UUID parametersUuid = headers .containsKey (PARAMETERS_UUID_HEADER ) ? UUID .fromString ((String ) headers .get (PARAMETERS_UUID_HEADER )) : null ;
66
- UUID reportUuid = headers .containsKey (REPORT_UUID_HEADER ) ? UUID .fromString ((String ) headers .get (REPORT_UUID_HEADER )) : null ;
67
- String reporterId = headers .containsKey (REPORTER_ID_HEADER ) ? (String ) headers .get (REPORTER_ID_HEADER ) : null ;
68
- String reportType = headers .containsKey (REPORT_TYPE_HEADER ) ? (String ) headers .get (REPORT_TYPE_HEADER ) : null ;
69
- VoltageInitRunContext runContext = new VoltageInitRunContext (networkUuid , variantId , receiver , reportUuid , reporterId , reportType , userId , parametersUuid , voltageLevelsIdsRestricted );
70
- return new VoltageInitResultContext (resultUuid , runContext );
61
+ String variantId = headers .get (VARIANT_ID_HEADER , String .class );
62
+ String receiver = headers .get (HEADER_RECEIVER , String .class );
63
+ String userId = headers .get (HEADER_USER_ID , String .class );
64
+ @ SuppressWarnings ("unchecked" )
65
+ Map <String , Double > voltageLevelsIdsRestricted = headers .get (VOLTAGE_LEVELS_IDS_RESTRICTED , Map .class );
66
+ UUID parametersUuid = headers .containsKey (PARAMETERS_UUID_HEADER ) ? UUID .fromString (headers .get (PARAMETERS_UUID_HEADER , String .class )) : null ;
67
+ UUID reportUuid = headers .containsKey (REPORT_UUID_HEADER ) ? UUID .fromString (headers .get (REPORT_UUID_HEADER , String .class )) : null ;
68
+ String reporterId = headers .containsKey (REPORTER_ID_HEADER ) ? headers .get (REPORTER_ID_HEADER , String .class ) : null ;
69
+ String reportType = headers .containsKey (REPORT_TYPE_HEADER ) ? headers .get (REPORT_TYPE_HEADER , String .class ) : null ;
70
+ return new VoltageInitResultContext (resultUuid , new VoltageInitRunContext (networkUuid , variantId , receiver , reportUuid , reporterId , reportType , userId , parametersUuid , voltageLevelsIdsRestricted ));
71
71
}
72
72
73
73
public Message <String > toMessage () {
0 commit comments