JAVA + HashMap for mappings
Some straightforward approach to the mapping of rule keys and indexes:\n\n\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\nclass So
Some straightforward approach to the mapping of rule keys and indexes:\n\n```\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\nclass Solution {\n    Map<String, Integer> mapping = new HashMap<>() {{\n        put("type", 0);\n        put("color", 1);\n        put("name", 2);\n    }};\n\n    public int countMatches(List<List<String>> items, String ruleKey, String ruleValue) {\n        int count = 0;\n        for (List<String> item : items) {\n            if (item.get(this.mapping.get(ruleKey)).equals(ruleValue)) {\n                count += 1;\n            }\n        }\n\n        return count;\n    }\n}\n```
['Java']