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
| 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());
| }
|
| }
|
|