Skip to content

Commit

Permalink
Harmonised InputData's payload property name to 'data'
Browse files Browse the repository at this point in the history
  • Loading branch information
sauterl committed Jul 1, 2024
1 parent 416605c commit d84dcf2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ data class RetrievableIdInputData(val id: String, override val comparison: Strin
* Cannot be converted to a [ContentElement]
*/
@Serializable
data class BooleanInputData(val value: Boolean, override val comparison: String? = "=="): InputData(){
data class BooleanInputData(val data: Boolean, override val comparison: String? = "=="): InputData(){
override val type = InputType.BOOLEAN
override fun toContent(): ContentElement<*> {
throw UnsupportedOperationException("Cannot derive content from BooleanInputData")
Expand All @@ -116,7 +116,7 @@ data class BooleanInputData(val value: Boolean, override val comparison: String?
* Cannot be converted to a [ContentElement]
*/
@Serializable
data class NumericInputData(val value: Double, override val comparison: String? = "==") : InputData(){
data class NumericInputData(val data: Double, override val comparison: String? = "==") : InputData(){
override val type = InputType.NUMERIC
override fun toContent(): ContentElement<*> {
throw UnsupportedOperationException("Cannot derive content from NumericInputData")
Expand All @@ -128,7 +128,7 @@ data class NumericInputData(val value: Double, override val comparison: String?
* Cannot be converted to a [ContentElement]
*/
@Serializable
data class DateInputData(val value: String, override val comparison: String? = "==") : InputData() {
data class DateInputData(val data: String, override val comparison: String? = "==") : InputData() {
override val type = InputType.DATE
override fun toContent(): ContentElement<*> {throw UnsupportedOperationException("Cannot derive content from DateInputData")}

Expand All @@ -137,6 +137,6 @@ data class DateInputData(val value: String, override val comparison: String? = "
*/
fun parseDate():Date{
val formatter = SimpleDateFormat("YYYY-mm-dd", Locale.ENGLISH)
return formatter.parse(value)
return formatter.parse(data)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,16 @@ class QueryParser(val schema: Schema) {
}
is BooleanInputData -> {
require(subfield.type == Type.BOOLEAN){"The given sub-field ${fieldAndAttributeName.first}.${fieldAndAttributeName.second}'s type is ${subfield.type}, which is not the expexted ${Type.BOOLEAN}"}
Value.Boolean(input.value)
Value.Boolean(input.data)
}
is NumericInputData -> {
when(subfield.type){
Type.DOUBLE -> Value.Double(input.value)
Type.INT -> Value.Int(input.value.toInt())
Type.LONG -> Value.Long(input.value.toLong())
Type.SHORT -> Value.Short(input.value.toInt().toShort())
Type.BYTE -> Value.Byte(input.value.toInt().toByte())
Type.FLOAT -> Value.Float(input.value.toFloat())
Type.DOUBLE -> Value.Double(input.data)
Type.INT -> Value.Int(input.data.toInt())
Type.LONG -> Value.Long(input.data.toLong())
Type.SHORT -> Value.Short(input.data.toInt().toShort())
Type.BYTE -> Value.Byte(input.data.toInt().toByte())
Type.FLOAT -> Value.Float(input.data.toFloat())
else -> throw IllegalArgumentException("Cannot work with NumericInputData $input but non-numerical sub-field $subfield")
}
}
Expand Down

0 comments on commit d84dcf2

Please sign in to comment.