I’ve upgraded to 2.3 from 2.0 and one of my rules suddenly stopped working. I only get warning messages but suspect it is linked to the cause of the issue
I get the following warnings: “Cannot reference the field ‘OFF’ before it is defined” and " Function2 is a raw type. References to generic type Function2<P1, P2, Result> should be parameterized"
Any idea? Simplified text of rule below:
// Imports
import org.eclipse.xtext.xbase.lib.Functions
import java.util.HashMap
import java.util.LinkedHashMap
var java.util.concurrent.locks.ReentrantLock lock = new java.util.concurrent.locks.ReentrantLock()
var HashMap<String, LinkedHashMap<String, Object>> scenes = newHashMap(
"0" -> (newLinkedHashMap(
"Light_LR_Kitchen" -> OFF,
"Light_LR_Bulb" -> OFF,
"Light_LR_Table" -> OFF)),
"100" -> (newLinkedHashMap(
"Light_LR_Kitchen" -> 100,
"Light_LR_Bulb" -> 100,
"Light_LR_Table" -> 100))
)
val org.eclipse.xtext.xbase.lib.Functions$Function2 updateLRLight = [String fixture, String fixtureValue, Number result |
logInfo("scene", "lambda: " + fixture + " = " + fixtureValue)
sendCommand(GF_Living_All.allMembers.findFirst[name.equals(fixture)], fixtureValue)
]
/**
* Selection item=Scene_LivingRoom mappings=[0=Off, 8=TV, 12=Soft,14=AllOn]
*/
rule "Scene LivingRoom"
» when
» » Item Scene_LivingRoom received command
» then
» » lock.lock()
» » try {
» » logInfo("scene", "LR selection changed")
» » switch (receivedCommand) {
» » » default : {
» » » » for (String fixtureName : scenes.get(receivedCommand.toString()).keySet()) {»
» » » » » var fixtureValue = scenes.get(receivedCommand.toString()).get(fixtureName).toString() as String
» » » » » logInfo("scene", "setting " + fixtureName + " = " + fixtureValue)
» » » » » updateLRLight.apply(fixtureName, fixtureValue)
» » » » }
» » » }
» » }
» » } finally {
» » » lock.unlock()
» » }
end