I am working on a project where i supposed to work with conversion based on the key. Since there are lot of key are there I was supposed to write a case for each key and logic for that code. But this approach leads to increase in lines of code.
So I was required to change the code by using map(key ->fun(length ,description, convertionMatchCase)
val h = scala.collection.mutable.Map(
"01" -> tagfunction(2, "Tag Length", "ToInt"),
"02" -> tagfunction(1, "Firmware version", "ToInt"),
"03" -> tagfunction(15, "IMEI", "ToASCII"),
"04" -> tagfunction(2, "Device ID", "ToInt"),
"10" -> tagfunction(2, "No of Archive records", "ToInt"),
"20" -> tagfunction(4, "Date and time", "ToInt"),
//"30" -> tagfunction(9, "Coordinates", "ToASCII"),
//"33" -> tagfunction(4, "Speed and direction", "ToASCII"),
"34" -> tagfunction(2, "Height", "ToSignedShort"),
"35" -> tagfunction(1, "HDOP", "ToInt"),
"40" -> tagfunction(2, "Status of device", "ToInt"),
"41" -> tagfunction(2, "Supply Voltage", "ToInt"),
"42" -> tagfunction(2, "Battery Voltage", "ToInt"),
"43" -> tagfunction(1, "Temperature of tracking device", "ToSignedByte"),
)
The problem is that function's inside the map are executing automatically(even when i'm using lazy after calling a single map(key) every thing was executing)
Could any one please suggest me some solution. Thanks you
tagfunctionsignature and how you use yourMap, it's not clear.