1 | /* | |
2 | * Copyright OpenSearch Contributors | |
3 | * SPDX-License-Identifier: Apache-2.0 | |
4 | */ | |
5 | ||
6 | ||
7 | package org.opensearch.sql.ast.expression; | |
8 | ||
9 | import com.google.common.collect.ImmutableList; | |
10 | import java.util.List; | |
11 | import lombok.Getter; | |
12 | import lombok.RequiredArgsConstructor; | |
13 | ||
14 | @Getter | |
15 | @RequiredArgsConstructor | |
16 | public enum IntervalUnit { | |
17 | UNKNOWN, | |
18 | ||
19 | MICROSECOND, | |
20 | SECOND, | |
21 | MINUTE, | |
22 | HOUR, | |
23 | DAY, | |
24 | WEEK, | |
25 | MONTH, | |
26 | QUARTER, | |
27 | YEAR, | |
28 | SECOND_MICROSECOND, | |
29 | MINUTE_MICROSECOND, | |
30 | MINUTE_SECOND, | |
31 | HOUR_MICROSECOND, | |
32 | HOUR_SECOND, | |
33 | HOUR_MINUTE, | |
34 | DAY_MICROSECOND, | |
35 | DAY_SECOND, | |
36 | DAY_MINUTE, | |
37 | DAY_HOUR, | |
38 | YEAR_MONTH; | |
39 | ||
40 | private static final List<IntervalUnit> INTERVAL_UNITS; | |
41 | ||
42 | static { | |
43 | ImmutableList.Builder<IntervalUnit> builder = new ImmutableList.Builder<>(); | |
44 | INTERVAL_UNITS = builder.add(IntervalUnit.values()).build(); | |
45 | } | |
46 | ||
47 | /** | |
48 | * Util method to get interval unit given the unit name. | |
49 | */ | |
50 | public static IntervalUnit of(String unit) { | |
51 |
1
1. of : replaced return value with null for org/opensearch/sql/ast/expression/IntervalUnit::of → KILLED |
return INTERVAL_UNITS.stream() |
52 |
2
1. lambda$of$0 : replaced boolean return with false for org/opensearch/sql/ast/expression/IntervalUnit::lambda$of$0 → KILLED 2. lambda$of$0 : replaced boolean return with true for org/opensearch/sql/ast/expression/IntervalUnit::lambda$of$0 → KILLED |
.filter(v -> unit.equalsIgnoreCase(v.name())) |
53 | .findFirst() | |
54 | .orElse(IntervalUnit.UNKNOWN); | |
55 | } | |
56 | } | |
Mutations | ||
51 |
1.1 |
|
52 |
1.1 2.2 |