/
TimeExpression.java
111 lines (87 loc) · 3.29 KB
/
TimeExpression.java
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
* Copyright (C) 2016 Fraunhofer Institut IOSB, Fraunhoferstr. 1, D 76131
* Karlsruhe, Germany.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.fraunhofer.iosb.ilt.sta.persistence.postgres.expression;
import com.querydsl.core.types.Expression;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.DateTimeExpression;
import com.querydsl.core.types.dsl.NumberExpression;
import java.sql.Timestamp;
/**
*
* @author scf
*/
public interface TimeExpression extends Expression {
public DateTimeExpression<Timestamp> getDateTime();
public boolean isUtc();
public default BooleanExpression eq(Expression<?> other) {
return simpleOpBool("=", other);
}
public default BooleanExpression neq(Expression<?> other) {
return eq(other).not();
}
public default BooleanExpression gt(Expression<?> other) {
return simpleOpBool(">", other);
}
public default BooleanExpression goe(Expression<?> other) {
return simpleOpBool(">=", other);
}
public default BooleanExpression lt(Expression<?> other) {
return simpleOpBool("<", other);
}
public default BooleanExpression loe(Expression<?> other) {
return simpleOpBool("<=", other);
}
public default BooleanExpression after(Expression<?> other) {
return simpleOpBool("a", other);
}
public default BooleanExpression before(Expression<?> other) {
return simpleOpBool("b", other);
}
public default BooleanExpression meets(Expression<?> other) {
return simpleOpBool("m", other);
}
public default BooleanExpression contains(Expression<?> other) {
return simpleOpBool("c", other);
}
public default BooleanExpression overlaps(Expression<?> other) {
return simpleOpBool("o", other);
}
public default BooleanExpression starts(Expression<?> other) {
return simpleOpBool("s", other);
}
public default BooleanExpression finishes(Expression<?> other) {
return simpleOpBool("f", other);
}
public default Expression<?> add(Expression<?> other) {
return simpleOp("+", other);
}
public default Expression<?> sub(Expression<?> other) {
return simpleOp("-", other);
}
public default Expression<?> mul(Expression<?> other) {
return simpleOp("*", other);
}
public default Expression<?> div(Expression<?> other) {
return simpleOp("/", other);
}
public Expression<?> simpleOp(String op, Expression<?> other);
public BooleanExpression simpleOpBool(String op, Expression<?> other);
public default NumberExpression<Integer> year() {
return getDateTime().year();
}
}