There are several ways to handle this. A HashMap is probably the worst or the options. Don’t try to simulate objects or other programming concepts in Rules DSL using maps and lambdas. You will end up with long, brittle, and ugly code.
You need to either change your approach to one that is better for us in Rules DSL or user a different language (jsr223) which let’s you write rules in jython, JavaScript, or Groovy.
A more Rules DSL approach would be Design Pattern: Associated Items.
You can also use Item metadata (I don’t have any experience with this but it is possible to set and access values on an item from rules. I think you need to be on a snapshot though.
Number is an interface, not a class. You can’t instantiate a Number, you have to instantiate a class that implements Number like BigDecimal or Integer.
Yes, you are wrong. Melts manager doesn’t work like that. If you have the referent to the local variable to the map, then that variable will continue to exist until it is removed from the map too.
In Java, Rules DSL, and almost every modern language a variable continues to exist until they’re are no more pointers to it. Then it gets garbage collected.
And while Rules DSL runs on top of the Java Virtual Machine and it has access to Java libraries, it is not Java. Far from it in fact.
That isn’t the purpose of that DP. The DP is about tagging Items that after related to each other and the operations you can do on those groups of Items. There is nothing that states that they have to be of the same type.
Unless I’m mistaken, none of the data you would save to the HashMap would be available to the widget anyway. Variables inside Rules are only available to the rules in that one .rules file. So this approach, and classes for that matter, was never going to work.
Never going to happen. Classes were deliberately left out of the Rules DSL. The Rules DSL is in the pieces of being replaced. And the availability of classes would help your makes a UI widget anyway.
If you want classes for other reasons, you can and should use JSR223.
For one thing the syntax is wrong.
Val Map<String, Object> myMap = newHadhMap
Then, as I said above, you can instantiate a Number. You have to instantiate a class that implements Number. Once you have that you can guest call put.
@vzorglub, this is actually a good example of the be XYProblem I think.