package com.mes.interaction; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; /** * 交互注册中心 * @author huang */ @Slf4j @Component public class DeviceInteractionRegistry { private final Map interactionMap = new HashMap<>(); public DeviceInteractionRegistry(List interactions) { if (interactions != null) { for (DeviceInteraction interaction : interactions) { if (interaction.getDeviceType() != null) { interactionMap.put(interaction.getDeviceType(), interaction); log.info("注册设备交互: {}", interaction.getDeviceType()); } } } } public DeviceInteraction getInteraction(String deviceType) { if (deviceType == null) { return null; } return interactionMap.get(deviceType); } public Map getInteractions() { return Collections.unmodifiableMap(interactionMap); } }