-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DOPE-228: added Between and NotBetween comparison and extension funct…
…ions
- Loading branch information
1 parent
43715c4
commit 60e228b
Showing
5 changed files
with
199 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
...kotlin/ch/ergon/dope/resolvable/expression/unaliased/type/relational/BetweenExpression.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package ch.ergon.dope.resolvable.expression.unaliased.type.relational | ||
|
||
import ch.ergon.dope.DopeQuery | ||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.validtype.BooleanType | ||
import ch.ergon.dope.validtype.ComparableType | ||
|
||
class BetweenExpression<T : ComparableType>( | ||
private val expression: TypeExpression<T>, | ||
private val start: TypeExpression<T>, | ||
private val end: TypeExpression<T>, | ||
) : TypeExpression<BooleanType> { | ||
override fun toDopeQuery(): DopeQuery { | ||
val expressionDopeQuery = expression.toDopeQuery() | ||
val startDopeQuery = start.toDopeQuery() | ||
val endDopeQuery = end.toDopeQuery() | ||
return DopeQuery( | ||
queryString = "${expressionDopeQuery.queryString} BETWEEN ${startDopeQuery.queryString} AND ${endDopeQuery.queryString}", | ||
parameters = expressionDopeQuery.parameters + startDopeQuery.parameters + endDopeQuery.parameters, | ||
) | ||
} | ||
} | ||
|
||
fun <T : ComparableType> TypeExpression<T>.between(start: TypeExpression<T>, end: TypeExpression<T>) = | ||
BetweenExpression(this, start, end) |
25 changes: 25 additions & 0 deletions
25
...lin/ch/ergon/dope/resolvable/expression/unaliased/type/relational/NotBetweenExpression.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package ch.ergon.dope.resolvable.expression.unaliased.type.relational | ||
|
||
import ch.ergon.dope.DopeQuery | ||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.validtype.BooleanType | ||
import ch.ergon.dope.validtype.ComparableType | ||
|
||
class NotBetweenExpression<T : ComparableType>( | ||
private val expression: TypeExpression<T>, | ||
private val start: TypeExpression<T>, | ||
private val end: TypeExpression<T>, | ||
) : TypeExpression<BooleanType> { | ||
override fun toDopeQuery(): DopeQuery { | ||
val expressionDopeQuery = expression.toDopeQuery() | ||
val startDopeQuery = start.toDopeQuery() | ||
val endDopeQuery = end.toDopeQuery() | ||
return DopeQuery( | ||
queryString = "${expressionDopeQuery.queryString} NOT BETWEEN ${startDopeQuery.queryString} AND ${endDopeQuery.queryString}", | ||
parameters = expressionDopeQuery.parameters + startDopeQuery.parameters + endDopeQuery.parameters, | ||
) | ||
} | ||
} | ||
|
||
fun <T : ComparableType> TypeExpression<T>.notBetween(start: TypeExpression<T>, end: TypeExpression<T>) = | ||
NotBetweenExpression(this, start, end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
crystal-map-connector/src/main/kotlin/ch/ergon/dope/extension/type/relational/Between.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package ch.ergon.dope.extension.type.relational | ||
|
||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.resolvable.expression.unaliased.type.relational.BetweenExpression | ||
import ch.ergon.dope.resolvable.expression.unaliased.type.relational.between | ||
import ch.ergon.dope.toDopeType | ||
import ch.ergon.dope.validtype.NumberType | ||
import ch.ergon.dope.validtype.StringType | ||
import com.schwarz.crystalapi.schema.CMField | ||
|
||
@JvmName("betweenNumber") | ||
fun CMField<out Number>.between(start: CMField<out Number>, end: CMField<out Number>): BetweenExpression<NumberType> = | ||
toDopeType().between(start.toDopeType(), end.toDopeType()) | ||
|
||
@JvmName("betweenNumber") | ||
fun CMField<out Number>.between(start: CMField<out Number>, end: TypeExpression<NumberType>): BetweenExpression<NumberType> = | ||
toDopeType().between(start.toDopeType(), end) | ||
|
||
@JvmName("betweenNumber") | ||
fun CMField<out Number>.between(start: TypeExpression<NumberType>, end: CMField<out Number>): BetweenExpression<NumberType> = | ||
toDopeType().between(start, end.toDopeType()) | ||
|
||
@JvmName("betweenNumber") | ||
fun CMField<out Number>.between(start: TypeExpression<NumberType>, end: TypeExpression<NumberType>): BetweenExpression<NumberType> = | ||
toDopeType().between(start, end) | ||
|
||
@JvmName("betweenNumber") | ||
fun TypeExpression<NumberType>.between(start: CMField<out Number>, end: CMField<out Number>): BetweenExpression<NumberType> = | ||
this.between(start.toDopeType(), end.toDopeType()) | ||
|
||
@JvmName("betweenNumber") | ||
fun TypeExpression<NumberType>.between(start: CMField<out Number>, end: TypeExpression<NumberType>): BetweenExpression<NumberType> = | ||
this.between(start.toDopeType(), end) | ||
|
||
@JvmName("betweenNumber") | ||
fun TypeExpression<NumberType>.between(start: TypeExpression<NumberType>, end: CMField<out Number>): BetweenExpression<NumberType> = | ||
this.between(start, end.toDopeType()) | ||
|
||
@JvmName("betweenString") | ||
fun CMField<String>.between(start: CMField<String>, end: CMField<String>): BetweenExpression<StringType> = | ||
toDopeType().between(start.toDopeType(), end.toDopeType()) | ||
|
||
@JvmName("betweenString") | ||
fun CMField<String>.between(start: CMField<String>, end: TypeExpression<StringType>): BetweenExpression<StringType> = | ||
toDopeType().between(start.toDopeType(), end) | ||
|
||
@JvmName("betweenString") | ||
fun CMField<String>.between(start: TypeExpression<StringType>, end: CMField<String>): BetweenExpression<StringType> = | ||
toDopeType().between(start, end.toDopeType()) | ||
|
||
@JvmName("betweenString") | ||
fun CMField<String>.between(start: TypeExpression<StringType>, end: TypeExpression<StringType>): BetweenExpression<StringType> = | ||
toDopeType().between(start, end) | ||
|
||
@JvmName("betweenString") | ||
fun TypeExpression<StringType>.between(start: CMField<String>, end: CMField<String>): BetweenExpression<StringType> = | ||
this.between(start.toDopeType(), end.toDopeType()) | ||
|
||
@JvmName("betweenString") | ||
fun TypeExpression<StringType>.between(start: CMField<String>, end: TypeExpression<StringType>): BetweenExpression<StringType> = | ||
this.between(start.toDopeType(), end) | ||
|
||
@JvmName("betweenString") | ||
fun TypeExpression<StringType>.between(start: TypeExpression<StringType>, end: CMField<String>): BetweenExpression<StringType> = | ||
this.between(start, end.toDopeType()) |
65 changes: 65 additions & 0 deletions
65
crystal-map-connector/src/main/kotlin/ch/ergon/dope/extension/type/relational/NotBetween.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package ch.ergon.dope.extension.type.relational | ||
|
||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.resolvable.expression.unaliased.type.relational.NotBetweenExpression | ||
import ch.ergon.dope.resolvable.expression.unaliased.type.relational.notBetween | ||
import ch.ergon.dope.toDopeType | ||
import ch.ergon.dope.validtype.NumberType | ||
import ch.ergon.dope.validtype.StringType | ||
import com.schwarz.crystalapi.schema.CMField | ||
|
||
@JvmName("betweenNumber") | ||
fun CMField<out Number>.notBetween(start: CMField<out Number>, end: CMField<out Number>): NotBetweenExpression<NumberType> = | ||
toDopeType().notBetween(start.toDopeType(), end.toDopeType()) | ||
|
||
@JvmName("betweenNumber") | ||
fun CMField<out Number>.notBetween(start: CMField<out Number>, end: TypeExpression<NumberType>): NotBetweenExpression<NumberType> = | ||
toDopeType().notBetween(start.toDopeType(), end) | ||
|
||
@JvmName("betweenNumber") | ||
fun CMField<out Number>.notBetween(start: TypeExpression<NumberType>, end: CMField<out Number>): NotBetweenExpression<NumberType> = | ||
toDopeType().notBetween(start, end.toDopeType()) | ||
|
||
@JvmName("betweenNumber") | ||
fun CMField<out Number>.notBetween(start: TypeExpression<NumberType>, end: TypeExpression<NumberType>): NotBetweenExpression<NumberType> = | ||
toDopeType().notBetween(start, end) | ||
|
||
@JvmName("betweenNumber") | ||
fun TypeExpression<NumberType>.notBetween(start: CMField<out Number>, end: CMField<out Number>): NotBetweenExpression<NumberType> = | ||
this.notBetween(start.toDopeType(), end.toDopeType()) | ||
|
||
@JvmName("betweenNumber") | ||
fun TypeExpression<NumberType>.notBetween(start: CMField<out Number>, end: TypeExpression<NumberType>): NotBetweenExpression<NumberType> = | ||
this.notBetween(start.toDopeType(), end) | ||
|
||
@JvmName("betweenNumber") | ||
fun TypeExpression<NumberType>.notBetween(start: TypeExpression<NumberType>, end: CMField<out Number>): NotBetweenExpression<NumberType> = | ||
this.notBetween(start, end.toDopeType()) | ||
|
||
@JvmName("betweenString") | ||
fun CMField<String>.notBetween(start: CMField<String>, end: CMField<String>): NotBetweenExpression<StringType> = | ||
toDopeType().notBetween(start.toDopeType(), end.toDopeType()) | ||
|
||
@JvmName("betweenString") | ||
fun CMField<String>.notBetween(start: CMField<String>, end: TypeExpression<StringType>): NotBetweenExpression<StringType> = | ||
toDopeType().notBetween(start.toDopeType(), end) | ||
|
||
@JvmName("betweenString") | ||
fun CMField<String>.notBetween(start: TypeExpression<StringType>, end: CMField<String>): NotBetweenExpression<StringType> = | ||
toDopeType().notBetween(start, end.toDopeType()) | ||
|
||
@JvmName("betweenString") | ||
fun CMField<String>.notBetween(start: TypeExpression<StringType>, end: TypeExpression<StringType>): NotBetweenExpression<StringType> = | ||
toDopeType().notBetween(start, end) | ||
|
||
@JvmName("betweenString") | ||
fun TypeExpression<StringType>.notBetween(start: CMField<String>, end: CMField<String>): NotBetweenExpression<StringType> = | ||
this.notBetween(start.toDopeType(), end.toDopeType()) | ||
|
||
@JvmName("betweenString") | ||
fun TypeExpression<StringType>.notBetween(start: CMField<String>, end: TypeExpression<StringType>): NotBetweenExpression<StringType> = | ||
this.notBetween(start.toDopeType(), end) | ||
|
||
@JvmName("betweenString") | ||
fun TypeExpression<StringType>.notBetween(start: TypeExpression<StringType>, end: CMField<String>): NotBetweenExpression<StringType> = | ||
this.notBetween(start, end.toDopeType()) |