Skip to content

Commit aaa63c2

Browse files
committed
Add exporting of struct definition in the "ExampleModule" class
1 parent 03be3d2 commit aaa63c2

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/main/java/me/jddev0/ExampleModule.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,26 @@ public DataObject load(List<DataObject> args, final int SCOPE_ID) {
8888
)
8989
), SCOPE_ID);
9090

91+
final DataObject.DataTypeConstraint TYPE_CONSTRAINT_OPTIONAL_TEXT = DataObject.DataTypeConstraint.fromAllowedTypes(Arrays.asList(
92+
DataObject.DataType.NULL, DataObject.DataType.TEXT
93+
));
94+
95+
final DataObject.DataTypeConstraint TYPE_CONSTRAINT_OPTIONAL_DOUBLE = DataObject.DataTypeConstraint.fromAllowedTypes(Arrays.asList(
96+
DataObject.DataType.NULL, DataObject.DataType.DOUBLE
97+
));
98+
99+
//Structs
100+
DataObject.StructObject exampleStruct = new DataObject.StructObject(new String[] {
101+
"$val",
102+
"$text",
103+
"$double"
104+
}, new DataObject.DataTypeConstraint[] {
105+
DataObject.CONSTRAINT_NORMAL,
106+
TYPE_CONSTRAINT_OPTIONAL_TEXT,
107+
TYPE_CONSTRAINT_OPTIONAL_DOUBLE
108+
});
109+
exportCollectionVariable("ExampleStruct", new DataObject().setStruct(exampleStruct));
110+
91111
//Accessing exported module variables within the module (The module name must be used [Use lmc.getName()])
92112
Map<String, DataObject> exportedVars = lii.getModuleExportedVariables(lmc.getName());
93113
if(exportedVars != null) {

0 commit comments

Comments
 (0)