| New file |
| | |
| | | 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(2019, 2024, 2025, 2026, 2027, 2028, 2029, 2030)); |
| | | return options; |
| | | } |
| | | } |