Skip to content

Commit

Permalink
Convert Invocation hierarchy to Kotlin (#1449)
Browse files Browse the repository at this point in the history
* Swap invocations to Kotlin

* Remove unused imports

* Surpress magic number false positives

* Fix unneeded constructor
  • Loading branch information
JPercival authored Nov 22, 2024
1 parent 40d6e50 commit 0f50f18
Show file tree
Hide file tree
Showing 64 changed files with 608 additions and 1,047 deletions.

This file was deleted.

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?
}

This file was deleted.

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
}

This file was deleted.

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
}
}

This file was deleted.

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]
}
}
}

This file was deleted.

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]
}
}
}

This file was deleted.

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
}
}

This file was deleted.

Loading

0 comments on commit 0f50f18

Please sign in to comment.