Skip to content

Commit ff27396

Browse files
committed
♻ Refactorisation EmploiDuTempsProxy
1 parent 22e45c2 commit ff27396

File tree

1 file changed

+1
-46
lines changed

1 file changed

+1
-46
lines changed

src/main/java/fr/umontp/edt/EmploiDuTempsProxy.java

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public final class EmploiDuTempsProxy implements InterfaceEmploiDuTemps {
2727
private IdentityHashMap<Professeur, Planning> cacheProfesseur;
2828
private HashMap<LocalDate, Planning> cacheDate;
2929
private HashMap<PlanningFiltreur, Planning> cachePlanningFiltreur;
30-
private HashMap<MultiKey<LocalDate, Groupe>, Planning> cacheDateGroupe;
3130

3231
@SuppressWarnings("deprecation")
3332
private EmploiDuTempsProxy() {
@@ -44,7 +43,6 @@ public void actualiser() {
4443
cacheDate = new HashMap<>();
4544
cacheProfesseur = new IdentityHashMap<>();
4645
cacheGroupe = new EnumMap<>(Groupe.class);
47-
cacheDateGroupe = new HashMap<>();
4846
cachePlanningFiltreur = new HashMap<>();
4947
emploiDuTemps.actualiser();
5048
}
@@ -96,8 +94,7 @@ public Planning getPlanningOf(LocalDate... dates) {
9694
*/
9795
@Override
9896
public Planning getPlanningOf(LocalDate date, Groupe groupe) {
99-
MultiKey<LocalDate, Groupe> multiKey = new MultiKey<>(date, groupe);
100-
return cacheDateGroupe.computeIfAbsent(multiKey, k -> getPlanningOf(k.key1).getPlanningOf(k.key2));
97+
return getPlanningOf(PlanningFiltreur.filtrer().par(date).par(groupe));
10198
}
10299

103100
/**
@@ -155,46 +152,4 @@ public Planning getPlanningOf(PlanningFiltreur planningFiltreur) {
155152
k -> emploiDuTemps.getPlanningOf(planningFiltreur));
156153
}
157154

158-
/**
159-
* Cette classe représente une combinaison de clefs
160-
*/
161-
private class MultiKey<K1, K2> {
162-
private K1 key1;
163-
private K2 key2;
164-
165-
public MultiKey(K1 key1, K2 key2) {
166-
this.key1 = key1;
167-
this.key2 = key2;
168-
}
169-
170-
@Override
171-
public boolean equals(Object o) {
172-
if (this == o)
173-
return true;
174-
if (o == null || getClass() != o.getClass())
175-
return false;
176-
177-
MultiKey<K1, K2> key = (MultiKey) o;
178-
179-
if (key1 != null ? !key1.equals(key.key1) : key.key1 != null)
180-
return false;
181-
if (key2 != null ? !key2.equals(key.key2) : key.key2 != null)
182-
return false;
183-
184-
return true;
185-
}
186-
187-
@Override
188-
public int hashCode() {
189-
int result = key1 != null ? key1.hashCode() : 0;
190-
result = 31 * result + (key2 != null ? key2.hashCode() : 0);
191-
return result;
192-
}
193-
194-
@Override
195-
public String toString() {
196-
return "[" + key1 + ", " + key2 + "]";
197-
}
198-
}
199-
200155
}

0 commit comments

Comments
 (0)