-
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.
Merge pull request #34 from ergon/feature/dope-226-add-array-functions
DOPE-226: added array functions, CM extension functions and tests
- Loading branch information
Showing
57 changed files
with
2,731 additions
and
1 deletion.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
...ch/ergon/dope/resolvable/expression/unaliased/type/arrayfunction/ArrayAppendExpression.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,17 @@ | ||
package ch.ergon.dope.resolvable.expression.unaliased.type.arrayfunction | ||
|
||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.validtype.ArrayType | ||
import ch.ergon.dope.validtype.ValidType | ||
|
||
class ArrayAppendExpression<T : ValidType>( | ||
array: TypeExpression<ArrayType<T>>, | ||
value: TypeExpression<T>, | ||
vararg additionalValues: TypeExpression<T>, | ||
) : ArrayFunctionExpression<T>("ARRAY_APPEND", array, value, *additionalValues) | ||
|
||
fun <T : ValidType> arrayAppend( | ||
array: TypeExpression<ArrayType<T>>, | ||
value: TypeExpression<T>, | ||
vararg additionalValues: TypeExpression<T>, | ||
) = ArrayAppendExpression(array, value, *additionalValues) |
10 changes: 10 additions & 0 deletions
10
...h/ergon/dope/resolvable/expression/unaliased/type/arrayfunction/ArrayAverageExpression.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,10 @@ | ||
package ch.ergon.dope.resolvable.expression.unaliased.type.arrayfunction | ||
|
||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.validtype.ArrayType | ||
import ch.ergon.dope.validtype.ValidType | ||
|
||
class ArrayAverageExpression<T : ValidType>(array: TypeExpression<ArrayType<T>>) : | ||
ArrayFunctionNumberExpression<T>("ARRAY_AVG", array) | ||
|
||
fun <T : ValidType> arrayAverage(array: TypeExpression<ArrayType<T>>) = ArrayAverageExpression(array) |
17 changes: 17 additions & 0 deletions
17
...ch/ergon/dope/resolvable/expression/unaliased/type/arrayfunction/ArrayConcatExpression.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,17 @@ | ||
package ch.ergon.dope.resolvable.expression.unaliased.type.arrayfunction | ||
|
||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.validtype.ArrayType | ||
import ch.ergon.dope.validtype.ValidType | ||
|
||
class ArrayConcatExpression<T : ValidType>( | ||
firstArray: TypeExpression<ArrayType<T>>, | ||
secondArray: TypeExpression<ArrayType<T>>, | ||
vararg additionalArrays: TypeExpression<ArrayType<T>>, | ||
) : ArrayFunctionExpression<T>("ARRAY_CONCAT", firstArray, secondArray, *additionalArrays) | ||
|
||
fun <T : ValidType> arrayConcat( | ||
firstArray: TypeExpression<ArrayType<T>>, | ||
secondArray: TypeExpression<ArrayType<T>>, | ||
vararg additionalArrays: TypeExpression<ArrayType<T>>, | ||
) = ArrayConcatExpression(firstArray, secondArray, *additionalArrays) |
24 changes: 24 additions & 0 deletions
24
.../ergon/dope/resolvable/expression/unaliased/type/arrayfunction/ArrayContainsExpression.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,24 @@ | ||
package ch.ergon.dope.resolvable.expression.unaliased.type.arrayfunction | ||
|
||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.resolvable.expression.unaliased.type.toDopeType | ||
import ch.ergon.dope.validtype.ArrayType | ||
import ch.ergon.dope.validtype.BooleanType | ||
import ch.ergon.dope.validtype.NumberType | ||
import ch.ergon.dope.validtype.StringType | ||
import ch.ergon.dope.validtype.ValidType | ||
|
||
class ArrayContainsExpression<T : ValidType>(array: TypeExpression<ArrayType<T>>, value: TypeExpression<T>) : | ||
ArrayFunctionNumberExpression<T>("ARRAY_CONTAINS", array, value) | ||
|
||
fun <T : ValidType> arrayContains(array: TypeExpression<ArrayType<T>>, value: TypeExpression<T>) = | ||
ArrayContainsExpression(array, value) | ||
|
||
fun arrayContains(array: TypeExpression<ArrayType<StringType>>, value: String) = | ||
arrayContains(array, value.toDopeType()) | ||
|
||
fun arrayContains(array: TypeExpression<ArrayType<NumberType>>, value: Number) = | ||
arrayContains(array, value.toDopeType()) | ||
|
||
fun arrayContains(array: TypeExpression<ArrayType<BooleanType>>, value: Boolean) = | ||
arrayContains(array, value.toDopeType()) |
10 changes: 10 additions & 0 deletions
10
.../ch/ergon/dope/resolvable/expression/unaliased/type/arrayfunction/ArrayCountExpression.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,10 @@ | ||
package ch.ergon.dope.resolvable.expression.unaliased.type.arrayfunction | ||
|
||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.validtype.ArrayType | ||
import ch.ergon.dope.validtype.ValidType | ||
|
||
class ArrayCountExpression<T : ValidType>(array: TypeExpression<ArrayType<T>>) : | ||
ArrayFunctionNumberExpression<T>("ARRAY_COUNT", array) | ||
|
||
fun <T : ValidType> arrayCount(array: TypeExpression<ArrayType<T>>) = ArrayCountExpression(array) |
10 changes: 10 additions & 0 deletions
10
.../ergon/dope/resolvable/expression/unaliased/type/arrayfunction/ArrayDistinctExpression.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,10 @@ | ||
package ch.ergon.dope.resolvable.expression.unaliased.type.arrayfunction | ||
|
||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.validtype.ArrayType | ||
import ch.ergon.dope.validtype.ValidType | ||
|
||
class ArrayDistinctExpression<T : ValidType>(array: TypeExpression<ArrayType<T>>) : | ||
ArrayFunctionExpression<T>("ARRAY_DISTINCT", array) | ||
|
||
fun <T : ValidType> arrayDistinct(array: TypeExpression<ArrayType<T>>) = ArrayDistinctExpression(array) |
11 changes: 11 additions & 0 deletions
11
...ch/ergon/dope/resolvable/expression/unaliased/type/arrayfunction/ArrayExceptExpression.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,11 @@ | ||
package ch.ergon.dope.resolvable.expression.unaliased.type.arrayfunction | ||
|
||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.validtype.ArrayType | ||
import ch.ergon.dope.validtype.ValidType | ||
|
||
class ArrayExceptExpression<T : ValidType>(array: TypeExpression<ArrayType<T>>, except: TypeExpression<ArrayType<T>>) : | ||
ArrayFunctionExpression<T>("ARRAY_EXCEPT", array, except) | ||
|
||
fun <T : ValidType> arrayExcept(array: TypeExpression<ArrayType<T>>, except: TypeExpression<ArrayType<T>>) = | ||
ArrayExceptExpression(array, except) |
16 changes: 16 additions & 0 deletions
16
...h/ergon/dope/resolvable/expression/unaliased/type/arrayfunction/ArrayFlattenExpression.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,16 @@ | ||
package ch.ergon.dope.resolvable.expression.unaliased.type.arrayfunction | ||
|
||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.resolvable.expression.unaliased.type.toDopeType | ||
import ch.ergon.dope.validtype.ArrayType | ||
import ch.ergon.dope.validtype.NumberType | ||
import ch.ergon.dope.validtype.ValidType | ||
|
||
class ArrayFlattenExpression<T : ValidType>(array: TypeExpression<ArrayType<T>>, depth: TypeExpression<NumberType>) : | ||
ArrayFunctionExpression<T>("ARRAY_FLATTEN", array, depth) | ||
|
||
fun <T : ValidType> arrayFlatten(array: TypeExpression<ArrayType<T>>, depth: TypeExpression<NumberType>) = | ||
ArrayFlattenExpression(array, depth) | ||
|
||
fun <T : ValidType> arrayFlatten(array: TypeExpression<ArrayType<T>>, depth: Number) = | ||
arrayFlatten(array, depth.toDopeType()) |
41 changes: 41 additions & 0 deletions
41
.../ergon/dope/resolvable/expression/unaliased/type/arrayfunction/ArrayFunctionExpression.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,41 @@ | ||
package ch.ergon.dope.resolvable.expression.unaliased.type.arrayfunction | ||
|
||
import ch.ergon.dope.DopeQuery | ||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.resolvable.operator.FunctionOperator | ||
import ch.ergon.dope.validtype.ArrayType | ||
import ch.ergon.dope.validtype.ValidType | ||
|
||
sealed class ArrayFunctionExpression<T : ValidType>( | ||
private val symbol: String, | ||
private val array: TypeExpression<ArrayType<T>>, | ||
private vararg val args: TypeExpression<out ValidType>, | ||
private val extra: TypeExpression<out ValidType>? = null, | ||
) : TypeExpression<ArrayType<T>>, FunctionOperator { | ||
override fun toDopeQuery(): DopeQuery { | ||
val arrayDopeQuery = array.toDopeQuery() | ||
val argsDopeQuery = args.map { it.toDopeQuery() } | ||
val extraDopeQuery = extra?.toDopeQuery() | ||
return DopeQuery( | ||
queryString = toFunctionQueryString(symbol, arrayDopeQuery, *argsDopeQuery.toTypedArray(), extra = extraDopeQuery), | ||
parameters = arrayDopeQuery.parameters + argsDopeQuery.fold( | ||
emptyMap(), | ||
) { argsParameters, field -> argsParameters + field.parameters } + extraDopeQuery?.parameters.orEmpty(), | ||
) | ||
} | ||
} | ||
|
||
sealed class ArrayFunctionNumberExpression<T : ValidType>( | ||
private val symbol: String, | ||
private val array: TypeExpression<ArrayType<T>>, | ||
private val value: TypeExpression<out ValidType>? = null, | ||
) : TypeExpression<ValidType>, FunctionOperator { | ||
override fun toDopeQuery(): DopeQuery { | ||
val arrayDopeQuery = array.toDopeQuery() | ||
val valueDopeQuery = value?.toDopeQuery() | ||
return DopeQuery( | ||
queryString = toFunctionQueryString(symbol, arrayDopeQuery, extra = valueDopeQuery), | ||
parameters = arrayDopeQuery.parameters + valueDopeQuery?.parameters.orEmpty(), | ||
) | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...ch/ergon/dope/resolvable/expression/unaliased/type/arrayfunction/ArrayIfNullExpression.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,10 @@ | ||
package ch.ergon.dope.resolvable.expression.unaliased.type.arrayfunction | ||
|
||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.validtype.ArrayType | ||
import ch.ergon.dope.validtype.ValidType | ||
|
||
class ArrayIfNullExpression<T : ValidType>(array: TypeExpression<ArrayType<T>>) : | ||
ArrayFunctionNumberExpression<T>("ARRAY_IFNULL", array) | ||
|
||
fun <T : ValidType> arrayIfNull(array: TypeExpression<ArrayType<T>>) = ArrayIfNullExpression(array) |
28 changes: 28 additions & 0 deletions
28
...ch/ergon/dope/resolvable/expression/unaliased/type/arrayfunction/ArrayInsertExpression.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,28 @@ | ||
package ch.ergon.dope.resolvable.expression.unaliased.type.arrayfunction | ||
|
||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.resolvable.expression.unaliased.type.toDopeType | ||
import ch.ergon.dope.validtype.ArrayType | ||
import ch.ergon.dope.validtype.NumberType | ||
import ch.ergon.dope.validtype.ValidType | ||
|
||
class ArrayInsertExpression<T : ValidType>( | ||
array: TypeExpression<ArrayType<T>>, | ||
position: TypeExpression<NumberType>, | ||
value: TypeExpression<T>, | ||
vararg additionalValues: TypeExpression<T>, | ||
) : ArrayFunctionExpression<T>("ARRAY_INSERT", array, position, value, *additionalValues) | ||
|
||
fun <T : ValidType> arrayInsert( | ||
array: TypeExpression<ArrayType<T>>, | ||
position: TypeExpression<NumberType>, | ||
value: TypeExpression<T>, | ||
vararg additionalValues: TypeExpression<T>, | ||
) = ArrayInsertExpression(array, position, value, *additionalValues) | ||
|
||
fun <T : ValidType> arrayInsert( | ||
array: TypeExpression<ArrayType<T>>, | ||
position: Number, | ||
value: TypeExpression<T>, | ||
vararg additionalValues: TypeExpression<T>, | ||
) = arrayInsert(array, position.toDopeType(), value, *additionalValues) |
17 changes: 17 additions & 0 deletions
17
...ergon/dope/resolvable/expression/unaliased/type/arrayfunction/ArrayIntersectExpression.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,17 @@ | ||
package ch.ergon.dope.resolvable.expression.unaliased.type.arrayfunction | ||
|
||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.validtype.ArrayType | ||
import ch.ergon.dope.validtype.ValidType | ||
|
||
class ArrayIntersectExpression<T : ValidType>( | ||
firstArray: TypeExpression<ArrayType<T>>, | ||
secondArray: TypeExpression<ArrayType<T>>, | ||
vararg additionalArrays: TypeExpression<ArrayType<T>>, | ||
) : ArrayFunctionExpression<T>("ARRAY_INTERSECT", firstArray, secondArray, *additionalArrays) | ||
|
||
fun <T : ValidType> arrayIntersect( | ||
firstArray: TypeExpression<ArrayType<T>>, | ||
secondArray: TypeExpression<ArrayType<T>>, | ||
vararg additionalArrays: TypeExpression<ArrayType<T>>, | ||
) = ArrayIntersectExpression(firstArray, secondArray, *additionalArrays) |
10 changes: 10 additions & 0 deletions
10
...ch/ergon/dope/resolvable/expression/unaliased/type/arrayfunction/ArrayLengthExpression.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,10 @@ | ||
package ch.ergon.dope.resolvable.expression.unaliased.type.arrayfunction | ||
|
||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.validtype.ArrayType | ||
import ch.ergon.dope.validtype.ValidType | ||
|
||
class ArrayLengthExpression<T : ValidType>(array: TypeExpression<ArrayType<T>>) : | ||
ArrayFunctionNumberExpression<T>("ARRAY_LENGTH", array) | ||
|
||
fun <T : ValidType> arrayLength(array: TypeExpression<ArrayType<T>>) = ArrayLengthExpression(array) |
10 changes: 10 additions & 0 deletions
10
...in/ch/ergon/dope/resolvable/expression/unaliased/type/arrayfunction/ArrayMaxExpression.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,10 @@ | ||
package ch.ergon.dope.resolvable.expression.unaliased.type.arrayfunction | ||
|
||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.validtype.ArrayType | ||
import ch.ergon.dope.validtype.ValidType | ||
|
||
class ArrayMaxExpression<T : ValidType>(array: TypeExpression<ArrayType<T>>) : | ||
ArrayFunctionNumberExpression<T>("ARRAY_MAX", array) | ||
|
||
fun <T : ValidType> arrayMax(array: TypeExpression<ArrayType<T>>) = ArrayMaxExpression(array) |
10 changes: 10 additions & 0 deletions
10
...in/ch/ergon/dope/resolvable/expression/unaliased/type/arrayfunction/ArrayMinExpression.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,10 @@ | ||
package ch.ergon.dope.resolvable.expression.unaliased.type.arrayfunction | ||
|
||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.validtype.ArrayType | ||
import ch.ergon.dope.validtype.ValidType | ||
|
||
class ArrayMinExpression<T : ValidType>(array: TypeExpression<ArrayType<T>>) : | ||
ArrayFunctionNumberExpression<T>("ARRAY_MIN", array) | ||
|
||
fun <T : ValidType> arrayMin(array: TypeExpression<ArrayType<T>>) = ArrayMinExpression(array) |
25 changes: 25 additions & 0 deletions
25
...n/ch/ergon/dope/resolvable/expression/unaliased/type/arrayfunction/ArrayMoveExpression.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.arrayfunction | ||
|
||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.resolvable.expression.unaliased.type.toDopeType | ||
import ch.ergon.dope.validtype.ArrayType | ||
import ch.ergon.dope.validtype.NumberType | ||
import ch.ergon.dope.validtype.ValidType | ||
|
||
class ArrayMoveExpression<T : ValidType>( | ||
array: TypeExpression<ArrayType<T>>, | ||
from: TypeExpression<NumberType>, | ||
to: TypeExpression<NumberType>, | ||
) : ArrayFunctionExpression<T>("ARRAY_MOVE", array, from, to) | ||
|
||
fun <T : ValidType> arrayMove(array: TypeExpression<ArrayType<T>>, from: TypeExpression<NumberType>, to: TypeExpression<NumberType>) = | ||
ArrayMoveExpression(array, from, to) | ||
|
||
fun <T : ValidType> arrayMove(array: TypeExpression<ArrayType<T>>, from: TypeExpression<NumberType>, to: Number) = | ||
arrayMove(array, from, to.toDopeType()) | ||
|
||
fun <T : ValidType> arrayMove(array: TypeExpression<ArrayType<T>>, from: Number, to: TypeExpression<NumberType>) = | ||
arrayMove(array, from.toDopeType(), to) | ||
|
||
fun <T : ValidType> arrayMove(array: TypeExpression<ArrayType<T>>, from: Number, to: Number) = | ||
arrayMove(array, from.toDopeType(), to.toDopeType()) |
16 changes: 16 additions & 0 deletions
16
.../ergon/dope/resolvable/expression/unaliased/type/arrayfunction/ArrayPositionExpression.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,16 @@ | ||
package ch.ergon.dope.resolvable.expression.unaliased.type.arrayfunction | ||
|
||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.resolvable.expression.unaliased.type.toDopeType | ||
import ch.ergon.dope.validtype.ArrayType | ||
import ch.ergon.dope.validtype.NumberType | ||
import ch.ergon.dope.validtype.ValidType | ||
|
||
class ArrayPositionExpression<T : ValidType>(array: TypeExpression<ArrayType<T>>, value: TypeExpression<NumberType>) : | ||
ArrayFunctionNumberExpression<T>("ARRAY_POSITION", array, value) | ||
|
||
fun <T : ValidType> arrayPosition(array: TypeExpression<ArrayType<T>>, value: TypeExpression<NumberType>) = | ||
ArrayPositionExpression(array, value) | ||
|
||
fun <T : ValidType> arrayPosition(array: TypeExpression<ArrayType<T>>, value: Number) = | ||
arrayPosition(array, value.toDopeType()) |
36 changes: 36 additions & 0 deletions
36
...h/ergon/dope/resolvable/expression/unaliased/type/arrayfunction/ArrayPrependExpression.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,36 @@ | ||
package ch.ergon.dope.resolvable.expression.unaliased.type.arrayfunction | ||
|
||
import ch.ergon.dope.DopeQuery | ||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.resolvable.operator.FunctionOperator | ||
import ch.ergon.dope.validtype.ArrayType | ||
import ch.ergon.dope.validtype.ValidType | ||
|
||
class ArrayPrependExpression<T : ValidType>( | ||
private val array: TypeExpression<ArrayType<T>>, | ||
private val value: TypeExpression<T>, | ||
private vararg val additionalValues: TypeExpression<T>, | ||
) : TypeExpression<ArrayType<T>>, FunctionOperator { | ||
override fun toDopeQuery(): DopeQuery { | ||
val arrayDopeQuery = array.toDopeQuery() | ||
val valueDopeQuery = value.toDopeQuery() | ||
val additionalValuesDopeQuery = additionalValues.map { it.toDopeQuery() } | ||
return DopeQuery( | ||
queryString = toFunctionQueryString( | ||
"ARRAY_PREPEND", | ||
valueDopeQuery, | ||
*additionalValuesDopeQuery.toTypedArray(), | ||
arrayDopeQuery, | ||
), | ||
parameters = arrayDopeQuery.parameters + valueDopeQuery.parameters + additionalValuesDopeQuery.fold( | ||
emptyMap(), | ||
) { argsParameters, field -> argsParameters + field.parameters }, | ||
) | ||
} | ||
} | ||
|
||
fun <T : ValidType> arrayPrepend( | ||
array: TypeExpression<ArrayType<T>>, | ||
value: TypeExpression<T>, | ||
vararg additionalValues: TypeExpression<T>, | ||
) = ArrayPrependExpression(array, value, *additionalValues) |
17 changes: 17 additions & 0 deletions
17
...in/ch/ergon/dope/resolvable/expression/unaliased/type/arrayfunction/ArrayPutExpression.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,17 @@ | ||
package ch.ergon.dope.resolvable.expression.unaliased.type.arrayfunction | ||
|
||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.validtype.ArrayType | ||
import ch.ergon.dope.validtype.ValidType | ||
|
||
class ArrayPutExpression<T : ValidType>( | ||
array: TypeExpression<ArrayType<T>>, | ||
value: TypeExpression<T>, | ||
vararg additionalValues: TypeExpression<T>, | ||
) : ArrayFunctionExpression<T>("ARRAY_PUT", array, value, *additionalValues) | ||
|
||
fun <T : ValidType> arrayPut( | ||
array: TypeExpression<ArrayType<T>>, | ||
value: TypeExpression<T>, | ||
vararg additionalValues: TypeExpression<T>, | ||
) = ArrayPutExpression(array, value, *additionalValues) |
17 changes: 17 additions & 0 deletions
17
...ch/ergon/dope/resolvable/expression/unaliased/type/arrayfunction/ArrayRemoveExpression.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,17 @@ | ||
package ch.ergon.dope.resolvable.expression.unaliased.type.arrayfunction | ||
|
||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.validtype.ArrayType | ||
import ch.ergon.dope.validtype.ValidType | ||
|
||
class ArrayRemoveExpression<T : ValidType>( | ||
array: TypeExpression<ArrayType<T>>, | ||
value: TypeExpression<T>, | ||
vararg additionalValues: TypeExpression<T>, | ||
) : ArrayFunctionExpression<T>("ARRAY_REMOVE", array, value, *additionalValues) | ||
|
||
fun <T : ValidType> arrayRemove( | ||
array: TypeExpression<ArrayType<T>>, | ||
value: TypeExpression<T>, | ||
vararg additionalValues: TypeExpression<T>, | ||
) = ArrayRemoveExpression(array, value, *additionalValues) |
20 changes: 20 additions & 0 deletions
20
...h/ergon/dope/resolvable/expression/unaliased/type/arrayfunction/ArrayReplaceExpression.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,20 @@ | ||
package ch.ergon.dope.resolvable.expression.unaliased.type.arrayfunction | ||
|
||
import ch.ergon.dope.resolvable.expression.TypeExpression | ||
import ch.ergon.dope.validtype.ArrayType | ||
import ch.ergon.dope.validtype.NumberType | ||
import ch.ergon.dope.validtype.ValidType | ||
|
||
class ArrayReplaceExpression<T : ValidType>( | ||
array: TypeExpression<ArrayType<T>>, | ||
toReplace: TypeExpression<T>, | ||
replaceWith: TypeExpression<T>, | ||
max: TypeExpression<NumberType>? = null, | ||
) : ArrayFunctionExpression<T>("ARRAY_REPLACE", array, toReplace, replaceWith, extra = max) | ||
|
||
fun <T : ValidType> arrayReplace( | ||
array: TypeExpression<ArrayType<T>>, | ||
toReplace: TypeExpression<T>, | ||
replaceWith: TypeExpression<T>, | ||
max: TypeExpression<NumberType>? = null, | ||
) = ArrayReplaceExpression(array, toReplace, replaceWith, max) |
Oops, something went wrong.