-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathRouter.java
More file actions
39 lines (29 loc) · 1007 Bytes
/
Router.java
File metadata and controls
39 lines (29 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.dtcc.exams.part2;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
public class Router {
//<PATH, CONTROLLER>
Map<String,String> routerMap = new LinkedHashMap<>();
public void add(String path, String controller) {routerMap.put(path, controller);}
public Integer size() {return routerMap.size();}
public String getController(String path) {
return routerMap.get(path);
}
public void update(String path, String studentController) {
routerMap.remove(path);
routerMap.put(path, studentController);
}
public void remove(String path) {routerMap.remove(path);
}
public String toString(){
String temp_string="";
//Entries, each entry
for(Map.Entry m:routerMap.entrySet()){
String key = (String)m.getKey();
String value = (String)m.getValue();
temp_string += (key + " -> " + value + "\n");
}
return temp_string;
}
}