-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert Invocation hierarchy to Kotlin (#1449)
* Swap invocations to Kotlin * Remove unused imports * Surpress magic number false positives * Fix unneeded constructor
- Loading branch information
Showing
64 changed files
with
608 additions
and
1,047 deletions.
There are no files selected for viewing
31 changes: 0 additions & 31 deletions
31
Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/model/Invocation.java
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
Src/java/cql-to-elm/src/main/java/org/cqframework/cql/cql2elm/model/Invocation.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,27 @@ | ||
package org.cqframework.cql.cql2elm.model | ||
|
||
import org.hl7.cql.model.DataType | ||
import org.hl7.elm.r1.Expression | ||
import org.hl7.elm.r1.TypeSpecifier | ||
|
||
/** | ||
* The Invocation interface is used to represent an invocation of an operator or function in the ELM | ||
* model. The ELM classes have named properties for their operands, but the Invocation interface | ||
* uses a list of expressions to represent the operands. The implementations of this interface are | ||
* responsible for managing the mapping between the list of expressions and the properties of the | ||
* ELM class. For example, the DateInvocation class maps properties for year, month, and day to the | ||
* first, second, and third expressions in the list of operands. This allows Invocations to be | ||
* handled generically in the CQL-to-ELM translation process. | ||
*/ | ||
interface Invocation { | ||
|
||
var signature: List<@JvmSuppressWildcards TypeSpecifier> | ||
|
||
var operands: List<@JvmSuppressWildcards Expression> | ||
|
||
var resultType: DataType? | ||
|
||
val expression: Expression | ||
|
||
var resolution: OperatorResolution? | ||
} |
52 changes: 0 additions & 52 deletions
52
.../main/java/org/cqframework/cql/cql2elm/model/invocation/AbstractExpressionInvocation.java
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
...rc/main/java/org/cqframework/cql/cql2elm/model/invocation/AbstractExpressionInvocation.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,22 @@ | ||
package org.cqframework.cql.cql2elm.model.invocation | ||
|
||
import org.cqframework.cql.cql2elm.model.Invocation | ||
import org.cqframework.cql.cql2elm.model.OperatorResolution | ||
import org.hl7.cql.model.DataType | ||
import org.hl7.elm.r1.Expression | ||
|
||
/** | ||
* The AbstractExpressionInvocation can be used to more simply make invocations for classes that | ||
* only extend Expression. | ||
*/ | ||
abstract class AbstractExpressionInvocation<E : Expression>(override val expression: E) : | ||
Invocation { | ||
|
||
override var resultType: DataType? | ||
get() = expression.resultType | ||
set(resultType) { | ||
expression.resultType = resultType | ||
} | ||
|
||
override var resolution: OperatorResolution? = null | ||
} |
35 changes: 0 additions & 35 deletions
35
...main/java/org/cqframework/cql/cql2elm/model/invocation/AggregateExpressionInvocation.java
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
...c/main/java/org/cqframework/cql/cql2elm/model/invocation/AggregateExpressionInvocation.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,22 @@ | ||
package org.cqframework.cql.cql2elm.model.invocation | ||
|
||
import org.hl7.elm.r1.AggregateExpression | ||
import org.hl7.elm.r1.Expression | ||
import org.hl7.elm.r1.TypeSpecifier | ||
|
||
class AggregateExpressionInvocation<A : AggregateExpression>(expression: A) : | ||
AbstractExpressionInvocation<A>(expression) { | ||
|
||
override var operands: List<Expression> | ||
get() = listOf(expression.source) | ||
set(operands) { | ||
require(operands.size == 1) { "Unary operator expected." } | ||
expression.source = operands[0] | ||
} | ||
|
||
override var signature: List<TypeSpecifier> | ||
get() = expression.signature | ||
set(signature) { | ||
expression.signature = signature | ||
} | ||
} |
38 changes: 0 additions & 38 deletions
38
...src/main/java/org/cqframework/cql/cql2elm/model/invocation/AnyInCodeSystemInvocation.java
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
...m/src/main/java/org/cqframework/cql/cql2elm/model/invocation/AnyInCodeSystemInvocation.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 org.cqframework.cql.cql2elm.model.invocation | ||
|
||
import org.hl7.elm.r1.AnyInCodeSystem | ||
import org.hl7.elm.r1.Expression | ||
|
||
/** Created by Bryn on 9/12/2018. */ | ||
class AnyInCodeSystemInvocation(expression: AnyInCodeSystem) : | ||
OperatorExpressionInvocation<AnyInCodeSystem>(expression) { | ||
override var operands: List<Expression> | ||
get() = listOfNotNull(expression.codes, expression.codesystemExpression) | ||
set(operands) { | ||
require(operands.size in 1..2) { | ||
"AnyInCodeSystem operator requires one or two operands." | ||
} | ||
expression.codes = operands[0] | ||
if (operands.size > 1) { | ||
expression.codesystemExpression = operands[1] | ||
} | ||
} | ||
} |
38 changes: 0 additions & 38 deletions
38
...m/src/main/java/org/cqframework/cql/cql2elm/model/invocation/AnyInValueSetInvocation.java
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
...elm/src/main/java/org/cqframework/cql/cql2elm/model/invocation/AnyInValueSetInvocation.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 org.cqframework.cql.cql2elm.model.invocation | ||
|
||
import org.hl7.elm.r1.AnyInValueSet | ||
import org.hl7.elm.r1.Expression | ||
|
||
/** Created by Bryn on 9/12/2018. */ | ||
class AnyInValueSetInvocation(expression: AnyInValueSet) : | ||
OperatorExpressionInvocation<AnyInValueSet>(expression) { | ||
override var operands: List<Expression> | ||
get() = listOfNotNull(expression.codes, expression.valuesetExpression) | ||
set(operands) { | ||
require(operands.size in 1..2) { | ||
"AnyInValueSet operator requires one or two operands." | ||
} | ||
expression.codes = operands[0] | ||
if (operands.size > 1) { | ||
expression.valuesetExpression = operands[1] | ||
} | ||
} | ||
} |
25 changes: 0 additions & 25 deletions
25
...rc/main/java/org/cqframework/cql/cql2elm/model/invocation/BinaryExpressionInvocation.java
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
.../src/main/java/org/cqframework/cql/cql2elm/model/invocation/BinaryExpressionInvocation.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,14 @@ | ||
package org.cqframework.cql.cql2elm.model.invocation | ||
|
||
import org.hl7.elm.r1.BinaryExpression | ||
import org.hl7.elm.r1.Expression | ||
|
||
class BinaryExpressionInvocation<B : BinaryExpression>(expression: B) : | ||
OperatorExpressionInvocation<B>(expression) { | ||
override var operands: List<Expression> | ||
get() = expression.operand | ||
set(operands) { | ||
require(operands.size == 2) { "BinaryExpression requires two operands." } | ||
expression.operand = operands | ||
} | ||
} |
36 changes: 0 additions & 36 deletions
36
...-to-elm/src/main/java/org/cqframework/cql/cql2elm/model/invocation/CombineInvocation.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.