I was able to solve using below solution. Now I can create multiple combinations and all are working fine. Hope somebody will find it helpful.
package com.example;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class MainApp {
public static void main(String[] args) throws JsonProcessingException {
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
HashMap propsBean = context.getBean("yamlMap", HashMap.class);
HashMap<String, AppConfig> priorityMap = (HashMap<String, AppConfig>) propsBean.get("priority");
List<String> keys = new ArrayList<>(priorityMap.keySet());
HashMap priority = (HashMap) propsBean.get("priority");
Map<Integer, AppConfig> MAP = new HashMap<>();
for (String k: keys) {
HashMap map = (HashMap) priority.get(k);
Integer key = Integer.parseInt(k.replace("[","").replace("]",""));
MAP.put(key, new AppConfig((String) map.get("type"),(String) map.get("country"),(List<String>) map.get("countryFriend")));
}
System.out.println(MAP);
}
}
solved Read yml file and convert it to HashMap instead of LinkedHashMap