Set state of items using Map

I am trying to set states of items using a map but dont succeed at the moment.
My rule:

import org.openhab.core.model.script.ScriptServiceUtil
import java.util.HashMap

val String Dateiname = "OpenHABStart.rules"


rule "Prozesse ausführen bei OpenHAB Start"
when
    System reached start level 100
then
    val String RuleName = Dateiname + ": \"Prozesse ausführen bei OpenHAB Start\""

    logInfo("Rule triggered", RuleName)

    val HashMap<GenericItem, Integer> itemsToSet = newHashMap(
        // "Multimedia_Badezimmer_Echo_Standardlautstaerke" -> 20,
        // "Multimedia_Badezimmer_Echo_TTS_Standardlautstaerke" -> 20,
        Steckdosen_Kueche_Eierkocher -> OFF
    )

    itemsToSet.entrySet().forEach[ GenericItem item, value |
        // val item = ScriptServiceUtil.getItemRegistry.getItem(itemName)
        if (item.state != value) {
            item.sendCommand(value)
        }
    ]
end

This leads me to the error Could not invoke method: org.openhab.core.items.GenericItem.getState() on instance: Steckdosen_Kueche_Eierkocher (Type=SwitchItem, State=OFF, Label=Eierkocher, Category=eierkocher)=OFF in OpenHABStart.

I tried to use ScriptServiceUtil.getItemRegistry.getItem(<name>) as described here or here with the name of the item as a key but got the error Could not invoke method: org.openhab.core.items.ItemRegistry.getItem(java.lang.String) on instance: org.openhab.core.internal.items.ItemRegistryImpl@6eed3c80 in OpenHABStart.

Can someone help me here? Thank you in advance! Ideally I’d like to store the item name (not the item itself) as I have to do some string replacement on the itemname in my forEach loop.

P.S. how do I have to annotate the values in the map if I want to store strings, intergers and ON/OFFs?

Edit: I found the problem: calling the entrySet() on the map.

	val HashMap<String, Integer> itemsToSet = newHashMap(
        "Multimedia_Badezimmer_Echo_Standardlautstaerke" -> 20,
        "Multimedia_Badezimmer_Echo_TTS_Standardlautstaerke" -> 20,
        "Steckdosen_Kueche_Eierkocher" -> OFF
    )

    itemsToSet.forEach[ String itemName, value |
        val item = ScriptServiceUtil.getItemRegistry.getItem(itemName)
        if (item.state != value) {
            item.sendCommand(value)
        }
    ]

works.

Now I only have to find out how to annotate the value of the map

Asking the last question in a separate topic