Skip to content

Commit 6fd0451

Browse files
committed
AC-832 Converted the package to kotlin
1 parent 44af769 commit 6fd0451

16 files changed

Lines changed: 331 additions & 395 deletions

openmrs-client/src/main/java/org/openmrs/mobile/models/typeConverters/AllergyReactionConverter.java

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* The contents of this file are subject to the OpenMRS Public License
3+
* Version 1.0 (the "License"); you may not use this file except in
4+
* compliance with the License. You may obtain a copy of the License at
5+
* http://license.openmrs.org
6+
*
7+
* Software distributed under the License is distributed on an "AS IS"
8+
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
9+
* License for the specific language governing rights and limitations
10+
* under the License.
11+
*
12+
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
13+
*/
14+
package org.openmrs.mobile.models.typeConverters
15+
16+
import androidx.room.TypeConverter
17+
import com.google.gson.GsonBuilder
18+
import com.google.gson.reflect.TypeToken
19+
import org.openmrs.mobile.models.AllergyReaction
20+
import java.io.Serializable
21+
import java.lang.reflect.Modifier
22+
23+
object AllergyReactionConverter : Serializable {
24+
@JvmStatic
25+
@TypeConverter
26+
fun fromString(value: String?): List<AllergyReaction> {
27+
val listType = object : TypeToken<List<AllergyReaction?>?>() {}.type
28+
val builder = GsonBuilder()
29+
builder.excludeFieldsWithModifiers(Modifier.FINAL, Modifier.TRANSIENT, Modifier.STATIC)
30+
val gson = builder.create()
31+
return gson.fromJson(value, listType)
32+
}
33+
34+
@JvmStatic
35+
@TypeConverter
36+
fun listToString(list: List<AllergyReaction?>?): String {
37+
val builder = GsonBuilder()
38+
builder.excludeFieldsWithModifiers(Modifier.FINAL, Modifier.TRANSIENT, Modifier.STATIC)
39+
val gson = builder.create()
40+
return gson.toJson(list)
41+
}
42+
}

openmrs-client/src/main/java/org/openmrs/mobile/models/typeConverters/FormResourceConverter.java

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* The contents of this file are subject to the OpenMRS Public License
3+
* Version 1.0 (the "License"); you may not use this file except in
4+
* compliance with the License. You may obtain a copy of the License at
5+
* http://license.openmrs.org
6+
*
7+
* Software distributed under the License is distributed on an "AS IS"
8+
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
9+
* License for the specific language governing rights and limitations
10+
* under the License.
11+
*
12+
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
13+
*/
14+
package org.openmrs.mobile.models.typeConverters
15+
16+
import androidx.room.TypeConverter
17+
import com.google.gson.GsonBuilder
18+
import com.google.gson.reflect.TypeToken
19+
import org.openmrs.mobile.databases.entities.FormResourceEntity
20+
import java.io.Serializable
21+
import java.lang.reflect.Modifier
22+
23+
object FormResourceConverter : Serializable {
24+
@JvmStatic
25+
@TypeConverter
26+
fun fromString(value: String?): List<FormResourceEntity> {
27+
val listType = object : TypeToken<List<FormResourceEntity?>?>() {}.type
28+
val builder = GsonBuilder()
29+
builder.excludeFieldsWithModifiers(Modifier.FINAL, Modifier.TRANSIENT, Modifier.STATIC)
30+
val gson = builder.create()
31+
return gson.fromJson(value, listType)
32+
}
33+
34+
@JvmStatic
35+
@TypeConverter
36+
fun listToString(list: List<FormResourceEntity?>?): String {
37+
val builder = GsonBuilder()
38+
builder.excludeFieldsWithModifiers(Modifier.FINAL, Modifier.TRANSIENT, Modifier.STATIC)
39+
val gson = builder.create()
40+
return gson.toJson(list)
41+
}
42+
}

openmrs-client/src/main/java/org/openmrs/mobile/models/typeConverters/ObservationListConverter.java

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* The contents of this file are subject to the OpenMRS Public License
3+
* Version 1.0 (the "License"); you may not use this file except in
4+
* compliance with the License. You may obtain a copy of the License at
5+
* http://license.openmrs.org
6+
*
7+
* Software distributed under the License is distributed on an "AS IS"
8+
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
9+
* License for the specific language governing rights and limitations
10+
* under the License.
11+
*
12+
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
13+
*/
14+
package org.openmrs.mobile.models.typeConverters
15+
16+
import androidx.room.TypeConverter
17+
import com.google.gson.GsonBuilder
18+
import com.google.gson.reflect.TypeToken
19+
import org.openmrs.mobile.models.Obscreate
20+
import java.io.Serializable
21+
import java.lang.reflect.Modifier
22+
23+
object ObservationListConverter : Serializable {
24+
@JvmStatic
25+
@TypeConverter
26+
fun fromString(value: String?): List<Obscreate> {
27+
val listType = object : TypeToken<List<Obscreate?>?>() {}.type
28+
val builder = GsonBuilder()
29+
builder.excludeFieldsWithModifiers(Modifier.FINAL, Modifier.TRANSIENT, Modifier.STATIC)
30+
val gson = builder.create()
31+
return gson.fromJson(value, listType)
32+
}
33+
34+
@JvmStatic
35+
@TypeConverter
36+
fun listToString(list: List<Obscreate?>?): String {
37+
val builder = GsonBuilder()
38+
builder.excludeFieldsWithModifiers(Modifier.FINAL, Modifier.TRANSIENT, Modifier.STATIC)
39+
val gson = builder.create()
40+
return gson.toJson(list)
41+
}
42+
}

openmrs-client/src/main/java/org/openmrs/mobile/models/typeConverters/PersonAddressConverter.java

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* The contents of this file are subject to the OpenMRS Public License
3+
* Version 1.0 (the "License"); you may not use this file except in
4+
* compliance with the License. You may obtain a copy of the License at
5+
* http://license.openmrs.org
6+
*
7+
* Software distributed under the License is distributed on an "AS IS"
8+
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
9+
* License for the specific language governing rights and limitations
10+
* under the License.
11+
*
12+
* Copyright (C) OpenMRS, LLC. All Rights Reserved.
13+
*/
14+
package org.openmrs.mobile.models.typeConverters
15+
16+
import androidx.room.TypeConverter
17+
import org.openmrs.mobile.models.PersonAddress
18+
import com.google.gson.GsonBuilder
19+
import com.google.gson.Gson
20+
import com.google.gson.reflect.TypeToken
21+
import java.io.Serializable
22+
import java.lang.reflect.Modifier
23+
24+
object PersonAddressConverter : Serializable {
25+
@TypeConverter
26+
fun fromString(value: String?): List<PersonAddress> {
27+
val listType = object : TypeToken<List<PersonAddress?>?>() {}.type
28+
val builder = GsonBuilder()
29+
builder.excludeFieldsWithModifiers(Modifier.FINAL, Modifier.TRANSIENT, Modifier.STATIC)
30+
val gson = builder.create()
31+
return gson.fromJson(value, listType)
32+
}
33+
34+
@TypeConverter
35+
fun listToString(list: List<PersonAddress?>?): String {
36+
val builder = GsonBuilder()
37+
builder.excludeFieldsWithModifiers(Modifier.FINAL, Modifier.TRANSIENT, Modifier.STATIC)
38+
val gson = builder.create()
39+
return gson.toJson(list)
40+
}
41+
}

0 commit comments

Comments
 (0)