/
Status.java
62 lines (47 loc) · 1.57 KB
/
Status.java
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package com.aventstack.extentreports;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import com.aventstack.extentreports.view.Ico;
import lombok.Getter;
@Getter
public enum Status {
INFO("Info", 10), PASS("Pass", 20), WARNING("Warning", 30), SKIP("Skip", 40), FAIL("Fail", 50);
private final Integer level;
private final String name;
Status(String name, Integer level) {
this.name = name;
this.level = level;
}
public static List<Status> getResolvedHierarchy(List<Status> status) {
List<Status> list = new ArrayList<>(status);
resolveHierarchy(list);
return list;
}
private static void resolveHierarchy(List<Status> status) {
status.sort(Comparator.comparing(Status::getLevel));
}
public static Status max(Collection<Status> status) {
return status.stream().max(Comparator.comparing(Status::getLevel)).orElse(PASS);
}
public static Status max(Status s1, Status s2) {
return s1.getLevel() > s2.getLevel() ? s1 : s2;
}
public static Status min(Collection<Status> status) {
return status.stream().min(Comparator.comparing(Status::getLevel)).orElse(PASS);
}
public static String i(String status) {
return Ico.ico(status).toString();
}
public static String i(Status status) {
return Ico.ico(status.toString()).toString();
}
public String toLower() {
return name.toLowerCase();
}
@Override
public String toString() {
return name;
}
}