Untitled

 avatar
unknown
plain_text
2 years ago
2.5 kB
10
Indexable
Map<String, Map<String, Integer>> theBoundariesByPlayerInEachVenue = new HashMap<>();

        for(Match match : matches) {
            Map<String, Integer> map = new HashMap<>();
            if(theBoundariesByPlayerInEachVenue.containsKey(match.getCity())) {
                int match1 = Integer.parseInt(match.getId());
                for(Delivery deliveri : deliveries) {
                    int boundary = Integer.parseInt(deliveri.getBatsmanRuns());
                    int matchId = Integer.parseInt(deliveri.getMatchId());
                    if (match1 == matchId) {
                        if (boundary == 4) {
                            if (map.containsKey(deliveri.getBatsman())) {
                                int batsManBoundaries = map.get(deliveri.getBatsman());
                                map.put(deliveri.getBatsman(), batsManBoundaries + 1);
                            } else {
                                map.put(deliveri.getBatsman(), 1);
                            }
                        }
                    }
                    else {
                        theBoundariesByPlayerInEachVenue.put(match.getCity(),map);
                    }
                }
            }
            else {
                int match1 = Integer.parseInt(match.getId());
                for(Delivery deliveri : deliveries) {
                    int boundary = Integer.parseInt(deliveri.getBatsmanRuns());
                    int matchId = Integer.parseInt(deliveri.getMatchId());
                    if (match1 == matchId) {
                        if (boundary == 4) {
                            if (map.containsKey(deliveri.getBatsman())) {
                                int batsManBoundaries = map.get(deliveri.getBatsman());
                                map.put(deliveri.getBatsman(), batsManBoundaries + 1);
                            } else {
                                map.put(deliveri.getBatsman(), 1);
                            }
                        }
                    } else {
                        theBoundariesByPlayerInEachVenue.put(match.getCity(), map);
                    }
                }
            }
        }
        for(Map.Entry<String, Map<String, Integer>> list : theBoundariesByPlayerInEachVenue.entrySet()) {
            System.out.println(list.getKey());
            for(Map.Entry<String, Integer> list2 : list.getValue().entrySet()) {
                System.out.println(list2);
            }
            System.out.println();
        }
Editor is loading...