19
19
/** Methods for simplifying the creation of mosaik meta information. */
20
20
public interface MetaUtils {
21
21
22
+ static Map <String , Object > createMetaWithPowerGrid (String type , ModelParams ... additionalModels ) {
23
+ return createMeta (type , ModelParams .simonaPowerGridEnvironment (), List .of (additionalModels ));
24
+ }
25
+
22
26
static Map <String , Object > createMeta (
23
27
String type , ModelParams simonaPowerGrid , ModelParams ... additionalModels ) {
24
28
return createMeta (type , simonaPowerGrid , List .of (additionalModels ));
25
29
}
26
30
27
31
@ SuppressWarnings ("unchecked" )
28
- static Map <String , Object > createMeta (
32
+ private static Map <String , Object > createMeta (
29
33
String type , ModelParams simonaPowerGrid , List <ModelParams > additionalModels ) {
30
34
JSONObject meta = new JSONObject ();
31
35
meta .put ("api_version" , Simulator .API_VERSION );
@@ -45,16 +49,26 @@ static Map<String, Object> createMeta(
45
49
@ SuppressWarnings ("unchecked" )
46
50
static JSONObject createObject (
47
51
boolean isPublic , List <String > params , List <String > attrs , List <String > triggers ) {
48
- JSONArray paramArray = new JSONArray ();
49
- if (params != null ) paramArray .addAll (params );
50
-
51
- JSONArray attrArray = new JSONArray ();
52
- if (attrs != null ) attrArray .addAll (attrs );
53
-
54
52
JSONObject obj = new JSONObject ();
55
53
obj .put ("public" , isPublic );
56
- obj .put ("params" , paramArray );
57
- obj .put ("attrs" , attrArray );
54
+
55
+ if (params != null ) {
56
+ JSONArray paramArray = new JSONArray ();
57
+ paramArray .addAll (params );
58
+ obj .put ("params" , paramArray );
59
+ }
60
+
61
+ if (attrs != null ) {
62
+ JSONArray attrArray = new JSONArray ();
63
+ attrArray .addAll (attrs );
64
+ obj .put ("attrs" , attrArray );
65
+ }
66
+
67
+ if (triggers != null ) {
68
+ JSONArray triggerArray = new JSONArray ();
69
+ triggerArray .addAll (triggers );
70
+ obj .put ("triggers" , triggerArray );
71
+ }
58
72
59
73
return obj ;
60
74
}
0 commit comments