xyc
4 小时以前 b509d59af23c6afba086fa3fb4c2afb47ab0becb
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package com.trafficaudit.holiday;
 
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
 
public final class HolidayConstants {
    public static final int COMPARISON_BASE_YEAR = 2026;
 
    public static final String TYPE_SPRING_FESTIVAL = "SPRING_FESTIVAL";
 
    public static final String TYPE_LABOR_DAY = "LABOR_DAY";
    public static final String TYPE_NATIONAL_DAY = "NATIONAL_DAY";
 
    public static final String CATEGORY_HOLIDAY = "HOLIDAY";
    public static final String CATEGORY_NON_HOLIDAY = "NON_HOLIDAY";
 
    public static final String MODE_RAIL = "RAIL";
    public static final String MODE_CIVIL_AVIATION = "CIVIL_AVIATION";
    public static final String MODE_ROAD = "ROAD";
    public static final String MODE_WATER = "WATER";
 
    public static final String ROAD_EXPRESSWAY = "EXPRESSWAY";
    public static final String ROAD_NATIONAL_PROVINCIAL = "NATIONAL_PROVINCIAL";
 
    public static final String VEHICLE_SMALL_PASSENGER = "SMALL_PASSENGER";
    public static final String VEHICLE_MEDIUM_SMALL_PASSENGER = "MEDIUM_SMALL_PASSENGER";
 
    public static final Map<String, String> HOLIDAY_TYPE_LABELS;
    public static final Map<String, String> DATE_CATEGORY_LABELS;
    public static final Map<String, String> TRANSPORT_MODE_LABELS;
    public static final Map<String, String> ROAD_CATEGORY_LABELS;
    public static final Map<String, String> VEHICLE_TYPE_LABELS;
 
    private static final Set<String> HOLIDAY_TYPES;
    private static final Set<String> DATE_CATEGORIES;
    private static final Set<String> TRANSPORT_MODES;
    private static final Set<String> ROAD_CATEGORIES;
    private static final Set<String> VEHICLE_TYPES;
 
    static {
        Map<String, String> holidayTypes = new LinkedHashMap<>();
        holidayTypes.put(TYPE_SPRING_FESTIVAL, "春节");
        holidayTypes.put(TYPE_LABOR_DAY, "五一");
        holidayTypes.put(TYPE_NATIONAL_DAY, "十一");
        HOLIDAY_TYPE_LABELS = Collections.unmodifiableMap(holidayTypes);
        HOLIDAY_TYPES = new LinkedHashSet<>(holidayTypes.keySet());
 
        Map<String, String> dateCategories = new LinkedHashMap<>();
        dateCategories.put(CATEGORY_HOLIDAY, "节假日");
        dateCategories.put(CATEGORY_NON_HOLIDAY, "非节假日");
        DATE_CATEGORY_LABELS = Collections.unmodifiableMap(dateCategories);
        DATE_CATEGORIES = new LinkedHashSet<>(dateCategories.keySet());
 
        Map<String, String> transportModes = new LinkedHashMap<>();
        transportModes.put(MODE_RAIL, "铁路");
        transportModes.put(MODE_CIVIL_AVIATION, "民航");
        transportModes.put(MODE_ROAD, "道路");
        transportModes.put(MODE_WATER, "水路");
        TRANSPORT_MODE_LABELS = Collections.unmodifiableMap(transportModes);
        TRANSPORT_MODES = new LinkedHashSet<>(transportModes.keySet());
 
        Map<String, String> roadCategories = new LinkedHashMap<>();
        roadCategories.put(ROAD_EXPRESSWAY, "高速公路");
        roadCategories.put(ROAD_NATIONAL_PROVINCIAL, "普通国省道");
        ROAD_CATEGORY_LABELS = Collections.unmodifiableMap(roadCategories);
        ROAD_CATEGORIES = new LinkedHashSet<>(roadCategories.keySet());
 
        Map<String, String> vehicleTypes = new LinkedHashMap<>();
        vehicleTypes.put(VEHICLE_SMALL_PASSENGER, "小客车");
        vehicleTypes.put(VEHICLE_MEDIUM_SMALL_PASSENGER, "中小客车");
        VEHICLE_TYPE_LABELS = Collections.unmodifiableMap(vehicleTypes);
        VEHICLE_TYPES = new LinkedHashSet<>(vehicleTypes.keySet());
    }
 
    private HolidayConstants() {
    }
 
    public static boolean supportsComparisonBase(int year) {
        return year == COMPARISON_BASE_YEAR;
    }
 
    public static boolean isValidHolidayType(String value) {
        return HOLIDAY_TYPES.contains(value);
    }
 
    public static boolean isValidDateCategory(String value) {
        return DATE_CATEGORIES.contains(value);
    }
 
    public static boolean isValidTransportMode(String value) {
        return TRANSPORT_MODES.contains(value);
    }
 
    public static boolean isValidRoadCategory(String value) {
        return ROAD_CATEGORIES.contains(value);
    }
 
    public static boolean isValidVehicleType(String value) {
        return VEHICLE_TYPES.contains(value);
    }
 
    public static Map<String, Object> optionMap() {
        Map<String, Object> options = new LinkedHashMap<>();
        options.put("holidayTypes", HOLIDAY_TYPE_LABELS);
        options.put("dateCategories", DATE_CATEGORY_LABELS);
        options.put("transportModes", TRANSPORT_MODE_LABELS);
        options.put("roadCategories", ROAD_CATEGORY_LABELS);
        options.put("vehicleTypes", VEHICLE_TYPE_LABELS);
        options.put("years", Arrays.asList(2024, 2025, 2026));
        return options;
    }
}