对比新文件 |
| | |
| | | package com.iailab.framework.common.enums; |
| | | |
| | | import cn.hutool.core.util.ArrayUtil; |
| | | import com.iailab.framework.common.core.IntArrayValuable; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * 时间间隔的枚举 |
| | | * |
| | | * @author dhb52 |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum DateIntervalEnum implements IntArrayValuable { |
| | | |
| | | DAY(1, "天"), |
| | | WEEK(2, "周"), |
| | | MONTH(3, "月"), |
| | | QUARTER(4, "季度"), |
| | | YEAR(5, "年") |
| | | ; |
| | | |
| | | public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DateIntervalEnum::getInterval).toArray(); |
| | | |
| | | /** |
| | | * 类型 |
| | | */ |
| | | private final Integer interval; |
| | | /** |
| | | * 名称 |
| | | */ |
| | | private final String name; |
| | | |
| | | @Override |
| | | public int[] array() { |
| | | return ARRAYS; |
| | | } |
| | | |
| | | public static DateIntervalEnum valueOf(Integer interval) { |
| | | return ArrayUtil.firstMatch(item -> item.getInterval().equals(interval), DateIntervalEnum.values()); |
| | | } |
| | | |
| | | } |