<types> <simpleType name="bool" baseType="boolean" /> <simpleType name="int" baseType="int" /> <structType name="struct"> <field name="field1" type="bool" /> <field name="field2" type="int" /> </structType> </types>And the associated service definition:
<services> <event name="myService" > <data name="myStruct" type="struct" /> </event> </services>The regular way to set the value for the fields would be:
// get the structure Data.Structure struct = (Data.Structure)service.getData("myStruct"); // set the value true for the "field1" field struct.setFieldBooleanValue("field1", true); // set the value 23 for the "field2" field struct.setFieldIntValue("field2", 23);But we can also define an annotated class:
@DataTag public class MyStruct { @FieldTag(field="field1") public boolean b; @FieldTag(field="field2") public int i; }Then we will be able to use directly instances of this class as values:
// get the structure Data struct = service.getData("myStruct"); MyStruct str = new MyStruct(); str.i = 23; str.b = true; // set the value for the whole structure struct.setValue(str);
Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence