-
Notifications
You must be signed in to change notification settings - Fork 274
Expand file tree
/
Copy pathLineFunction.java
More file actions
48 lines (39 loc) · 1.2 KB
/
LineFunction.java
File metadata and controls
48 lines (39 loc) · 1.2 KB
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
40
41
42
43
44
45
46
47
48
package subway.controller.function;
import subway.controller.LineController;
import subway.controller.MainController;
import java.util.Arrays;
import java.util.Objects;
public enum LineFunction implements Function {
REGISTER_LINE("1", "노선 등록", LineController::addLine),
DELETE_LINE("2", "노선 삭제", LineController::deleteLineByName),
SEARCH_LINE("3", "노선 조회", LineController::lines),
BACK("B", "돌아가기", MainController::redirect);
private String code;
private String title;
private Runnable function;
LineFunction(String code, String title, Runnable function) {
this.code = code;
this.title = title;
this.function = function;
}
@Override
public String getCode() {
return code;
}
@Override
public String getTitle() {
return title;
}
@Override
public Runnable getFunction() {
return function;
}
public static void callBy(String code) {
Arrays.stream(LineFunction.values())
.filter(function -> Objects.equals(function.getCode(), code))
.findAny()
.get()
.getFunction()
.run();
}
}