File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed
Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change 11package fr .france ;
22
3- import org . hamcrest . Matcher ;
3+ import java . util . List ;
44
55import fr .france .outils .OutilsDepartement ;
66import fr .france .outils .OutilsRegion ;
@@ -164,8 +164,8 @@ public String getNom() {
164164 return nom ;
165165 }
166166
167- public Matcher getCaumunes () {
168- return null ;
167+ public List < Caumune > getCaumunes () {
168+ return OutilsRegion . getCaumunes ( this ) ;
169169 }
170170
171171}
Original file line number Diff line number Diff line change 11package fr .france .outils ;
22
3+ import java .util .ArrayList ;
4+ import java .util .EnumMap ;
5+ import java .util .List ;
6+ import java .util .Map ;
7+
8+ import fr .france .Caumune ;
9+ import fr .france .Departement ;
310import fr .france .Region ;
411
512/**
@@ -19,9 +26,26 @@ private OutilsRegion() {
1926 }
2027
2128 private static final RepertoireGenerique <Region > REPERTOIRE_REGION = new RepertoireGenerique <>(Region .class );
29+ private static final Map <Region , List <Caumune >> REPERTOIRE_CAUMUNE = initialiserRepertoireCaumune ();
2230
2331 public static Region rechercherParNom (String nom ) {
2432 return REPERTOIRE_REGION .rechercherParNom (nom );
2533 }
2634
35+ public static List <Caumune > getCaumunes (Region region ) {
36+ return REPERTOIRE_CAUMUNE .get (region );
37+ }
38+
39+ private static Map <Region , List <Caumune >> initialiserRepertoireCaumune () {
40+ EnumMap <Region , List <Caumune >> result = new EnumMap <>(Region .class );
41+ for (Region region : Region .values ()) {
42+ List <Caumune > caumunes = new ArrayList <>();
43+ for (Departement departement : region .getDepartements ()) {
44+ caumunes .addAll (departement .getCaumunes ());
45+ }
46+ result .put (region , caumunes );
47+ }
48+ return result ;
49+ }
50+
2751}
You can’t perform that action at this time.
0 commit comments