-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathDateUnitExpression.java
More file actions
51 lines (39 loc) · 1.22 KB
/
Copy pathDateUnitExpression.java
File metadata and controls
51 lines (39 loc) · 1.22 KB
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
/*-
* #%L
* JSQLParser library
* %%
* Copyright (C) 2004 - 2019 JSQLParser
* %%
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
package net.sf.jsqlparser.expression;
import java.util.Locale;
import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
import java.util.Objects;
public class DateUnitExpression extends ASTNodeAccessImpl implements Expression {
private final DateUnit type;
public DateUnitExpression(DateUnit type) {
this.type = Objects.requireNonNull(type);
}
public DateUnitExpression(String DateUnitStr) {
this.type = Objects.requireNonNull(DateUnit.from(DateUnitStr));
}
public DateUnit getType() {
return type;
}
@Override
public <T, S> T accept(ExpressionVisitor<T> expressionVisitor, S context) {
return expressionVisitor.visit(this, context);
}
@Override
public String toString() {
return type.toString();
}
public enum DateUnit {
CENTURY, DECADE, YEAR, QUARTER, MONTH, WEEK, DAY, HOUR, MINUTE, SECOND, MILLISECOND, MICROSECOND, NANOSECOND;
public static DateUnit from(String UnitStr) {
return Enum.valueOf(DateUnit.class, UnitStr.toUpperCase(Locale.ROOT));
}
}
}