package pm.j4.petroleum.util.data; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import pm.j4.petroleum.PetroleumMod; import pm.j4.petroleum.util.module.ModuleBase; /** * The type Category. */ public class Category { /** * Gets category map. * * @return the category map */ public static Map> getCategoryMap() { List modules = PetroleumMod.getActiveMods(); Map> categoryMap = new HashMap<>(); modules.forEach(module -> { if (!categoryMap.containsKey(module.getCategory())) { List m = new ArrayList<>(); m.add(module); categoryMap.put(module.getCategory(), m); } else { List m = categoryMap.get(module.getCategory()); List nm = new ArrayList<>(); nm.addAll(m); nm.add(module); categoryMap.replace(module.getCategory(), nm); } }); return categoryMap; } /** * Gets by category. * * @param category the category * @return the by category */ public static List getByCategory(String category) { return getCategoryMap().containsKey(category) ? getCategoryMap().get(category) : new ArrayList<>(); } }