from my understanding classes are not available in rules. Therefore I’m using a
<key>,<Object> pairs to store a collection of Objects, like:
"obj01_propertyA" -> GenericItem "obj01_propertyB" -> GenericItem "obj01_propertyC" -> Number "obj02_propertyA" -> GenericItem ...
This simulates a collection of objects of a class containing 3 poperties of different data types. Then I use lambda functions to build the relative methods for creating a new object or disposing it.
So my code looks like this:
val HashMap<String, Object> myObjs = new HashMap val Functions$Function4<Map<String, Object>, GenericItem, GenericItem, Number, Boolean> myObj_create = [ objMap, myItem1, myItem2, theNumber | var String itemKey = myItem1.name objMap.put(itemKey + "_propertyA", myItem1) objMap.put(itemKey + "_propertyB", myItem2) var Number nTmp = new Number nTmp = theNumber objMap.put(itemKey + "_propertyC", nTmp) return true ]
Item objects are pointers to objects, so I don’t need to create copies of them to put into the
HashMap. But when it comes to the
Number object, I think I cannot directly add the incoming parameter
theNumber to the HashMap, because once exited from the function it doesn’t exist anymore. Then I decided to create a
new Number but I get the follwoing error
Could not invoke constructor: java.lang.Number.Number()
What is it that I’m doing wrong?