|
| 1 | +package de.jaggl.sqlbuilder.core.columns.datetime; |
| 2 | + |
| 3 | +import static de.jaggl.sqlbuilder.core.conditions.GenericCondition.GenericConditionType.IS_BETWEEN; |
| 4 | +import static de.jaggl.sqlbuilder.core.conditions.GenericCondition.GenericConditionType.IS_EQUAL_TO; |
| 5 | +import static de.jaggl.sqlbuilder.core.conditions.GenericCondition.GenericConditionType.IS_GREATER_THAN; |
| 6 | +import static de.jaggl.sqlbuilder.core.conditions.GenericCondition.GenericConditionType.IS_GREATER_THAN_OR_EQUAL_TO; |
| 7 | +import static de.jaggl.sqlbuilder.core.conditions.GenericCondition.GenericConditionType.IS_LESS_THAN; |
| 8 | +import static de.jaggl.sqlbuilder.core.conditions.GenericCondition.GenericConditionType.IS_LESS_THAN_OR_EQUAL_TO; |
| 9 | +import static de.jaggl.sqlbuilder.core.conditions.GenericCondition.GenericConditionType.IS_NOT_EQUAL_TO; |
| 10 | +import static de.jaggl.sqlbuilder.core.conditions.GenericCondition.GenericConditionType.IS_NOT_NULL; |
| 11 | +import static de.jaggl.sqlbuilder.core.conditions.GenericCondition.GenericConditionType.IS_NULL; |
| 12 | +import static java.sql.Types.DATE; |
| 13 | + |
| 14 | +import java.time.LocalTime; |
| 15 | + |
| 16 | +import de.jaggl.sqlbuilder.core.columns.Column; |
| 17 | +import de.jaggl.sqlbuilder.core.columns.ColumnDefinition; |
| 18 | +import de.jaggl.sqlbuilder.core.conditions.Condition; |
| 19 | +import de.jaggl.sqlbuilder.core.conditions.GenericCondition; |
| 20 | +import de.jaggl.sqlbuilder.core.domain.Placeholder; |
| 21 | +import de.jaggl.sqlbuilder.core.schema.Table; |
| 22 | +import lombok.ToString; |
| 23 | + |
| 24 | +/** |
| 25 | + * @author Martin Schumacher |
| 26 | + * |
| 27 | + * @since 2.0.0 |
| 28 | + */ |
| 29 | +@ToString(callSuper = true) |
| 30 | +public class TimeColumn extends Column |
| 31 | +{ |
| 32 | + public TimeColumn(Table table, String name, String alias, ColumnDefinition columnDefinition) |
| 33 | + { |
| 34 | + super(table, name, alias, columnDefinition, DATE); |
| 35 | + } |
| 36 | + |
| 37 | + public TimeColumn as(String alias) |
| 38 | + { |
| 39 | + return new TimeColumn(table, name, alias, columnDefinition); |
| 40 | + } |
| 41 | + |
| 42 | + public Condition isEqualTo(LocalTime value) |
| 43 | + { |
| 44 | + return value == null ? new GenericCondition(IS_NULL, this) : new GenericCondition(IS_EQUAL_TO, this, value); |
| 45 | + } |
| 46 | + |
| 47 | + public Condition eq(LocalTime value) |
| 48 | + { |
| 49 | + return isEqualTo(value); |
| 50 | + } |
| 51 | + |
| 52 | + public Condition isNotEqualTo(LocalTime value) |
| 53 | + { |
| 54 | + return value == null ? new GenericCondition(IS_NOT_NULL, this) : new GenericCondition(IS_NOT_EQUAL_TO, this, value); |
| 55 | + } |
| 56 | + |
| 57 | + public Condition nEq(LocalTime value) |
| 58 | + { |
| 59 | + return isNotEqualTo(value); |
| 60 | + } |
| 61 | + |
| 62 | + public Condition isAfter(LocalTime value) |
| 63 | + { |
| 64 | + return new GenericCondition(IS_GREATER_THAN, this, value); |
| 65 | + } |
| 66 | + |
| 67 | + public Condition isAfter(Column otherColumn) |
| 68 | + { |
| 69 | + return new GenericCondition(IS_GREATER_THAN, this, otherColumn); |
| 70 | + } |
| 71 | + |
| 72 | + public Condition isAfter(Placeholder placeholder) |
| 73 | + { |
| 74 | + return new GenericCondition(IS_GREATER_THAN, this, placeholder); |
| 75 | + } |
| 76 | + |
| 77 | + public Condition isAfterOrEqualTo(LocalTime value) |
| 78 | + { |
| 79 | + return new GenericCondition(IS_GREATER_THAN_OR_EQUAL_TO, this, value); |
| 80 | + } |
| 81 | + |
| 82 | + public Condition isAfterOrEqualTo(Column otherColumn) |
| 83 | + { |
| 84 | + return new GenericCondition(IS_GREATER_THAN_OR_EQUAL_TO, this, otherColumn); |
| 85 | + } |
| 86 | + |
| 87 | + public Condition isAfterOrEqualTo(Placeholder placeholder) |
| 88 | + { |
| 89 | + return new GenericCondition(IS_GREATER_THAN_OR_EQUAL_TO, this, placeholder); |
| 90 | + } |
| 91 | + |
| 92 | + public Condition isBefore(LocalTime value) |
| 93 | + { |
| 94 | + return new GenericCondition(IS_LESS_THAN, this, value); |
| 95 | + } |
| 96 | + |
| 97 | + public Condition isBefore(Column otherColumn) |
| 98 | + { |
| 99 | + return new GenericCondition(IS_LESS_THAN, this, otherColumn); |
| 100 | + } |
| 101 | + |
| 102 | + public Condition isBefore(Placeholder placeholder) |
| 103 | + { |
| 104 | + return new GenericCondition(IS_LESS_THAN, this, placeholder); |
| 105 | + } |
| 106 | + |
| 107 | + public Condition isBeforeOrEqualTo(LocalTime value) |
| 108 | + { |
| 109 | + return new GenericCondition(IS_LESS_THAN_OR_EQUAL_TO, this, value); |
| 110 | + } |
| 111 | + |
| 112 | + public Condition isBeforeOrEqualTo(Column otherColumn) |
| 113 | + { |
| 114 | + return new GenericCondition(IS_LESS_THAN_OR_EQUAL_TO, this, otherColumn); |
| 115 | + } |
| 116 | + |
| 117 | + public Condition isBeforeOrEqualTo(Placeholder placeholder) |
| 118 | + { |
| 119 | + return new GenericCondition(IS_LESS_THAN_OR_EQUAL_TO, this, placeholder); |
| 120 | + } |
| 121 | + |
| 122 | + public Condition isBetween(LocalTime value1, LocalTime value2) |
| 123 | + { |
| 124 | + return new GenericCondition(IS_BETWEEN, this, value1, value2); |
| 125 | + } |
| 126 | + |
| 127 | + public Condition isBetween(Column otherColumn1, Column otherColumn2) |
| 128 | + { |
| 129 | + return new GenericCondition(IS_BETWEEN, this, otherColumn1, otherColumn2); |
| 130 | + } |
| 131 | + |
| 132 | + public Condition isBetween(LocalTime value, Column otherColumn) |
| 133 | + { |
| 134 | + return new GenericCondition(IS_BETWEEN, this, value, otherColumn); |
| 135 | + } |
| 136 | + |
| 137 | + public Condition isBetween(Column otherColumn, LocalTime value) |
| 138 | + { |
| 139 | + return new GenericCondition(IS_BETWEEN, this, otherColumn, value); |
| 140 | + } |
| 141 | + |
| 142 | + public Condition isBetween(Column otherColumn, Placeholder placeholder) |
| 143 | + { |
| 144 | + return new GenericCondition(IS_BETWEEN, this, otherColumn, placeholder); |
| 145 | + } |
| 146 | + |
| 147 | + public Condition isBetween(LocalTime value, Placeholder placeholder) |
| 148 | + { |
| 149 | + return new GenericCondition(IS_BETWEEN, this, value, placeholder); |
| 150 | + } |
| 151 | + |
| 152 | + public Condition isBetween(Placeholder placeholder, LocalTime value) |
| 153 | + { |
| 154 | + return new GenericCondition(IS_BETWEEN, this, placeholder, value); |
| 155 | + } |
| 156 | + |
| 157 | + public Condition isBetween(Placeholder placeholder, Column otherColumn) |
| 158 | + { |
| 159 | + return new GenericCondition(IS_BETWEEN, this, placeholder, otherColumn); |
| 160 | + } |
| 161 | +} |
0 commit comments