Converts TypeConverters to Kotlin.
This commit is contained in:
@@ -1,19 +0,0 @@
|
|||||||
package com.majinnaibu.monstercards.data.converters;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.room.TypeConverter;
|
|
||||||
|
|
||||||
import com.majinnaibu.monstercards.data.enums.ArmorType;
|
|
||||||
|
|
||||||
public class ArmorTypeConverter {
|
|
||||||
|
|
||||||
@TypeConverter
|
|
||||||
public static String fromArmorType(@NonNull ArmorType armorType) {
|
|
||||||
return armorType.stringValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@TypeConverter
|
|
||||||
public static ArmorType armorTypeFromStringValue(String stringValue) {
|
|
||||||
return ArmorType.valueOfString(stringValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.majinnaibu.monstercards.data.converters
|
||||||
|
|
||||||
|
import androidx.room.TypeConverter
|
||||||
|
import com.majinnaibu.monstercards.data.enums.ArmorType
|
||||||
|
import com.majinnaibu.monstercards.data.enums.ArmorType.Companion.valueOfString
|
||||||
|
|
||||||
|
object ArmorTypeConverter {
|
||||||
|
@JvmStatic
|
||||||
|
@TypeConverter
|
||||||
|
fun fromArmorType(armorType: ArmorType): String {
|
||||||
|
return armorType.stringValue
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@TypeConverter
|
||||||
|
fun armorTypeFromStringValue(stringValue: String?): ArmorType {
|
||||||
|
return valueOfString(stringValue!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package com.majinnaibu.monstercards.data.converters;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.room.TypeConverter;
|
|
||||||
|
|
||||||
import com.majinnaibu.monstercards.data.enums.ChallengeRating;
|
|
||||||
|
|
||||||
public class ChallengeRatingConverter {
|
|
||||||
|
|
||||||
@TypeConverter
|
|
||||||
public static String fromChallengeRating(@NonNull ChallengeRating challengeRating) {
|
|
||||||
return challengeRating.stringValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@TypeConverter
|
|
||||||
public static ChallengeRating challengeRatingFromStringValue(String stringValue) {
|
|
||||||
return ChallengeRating.valueOfString(stringValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.majinnaibu.monstercards.data.converters
|
||||||
|
|
||||||
|
import androidx.room.TypeConverter
|
||||||
|
import com.majinnaibu.monstercards.data.enums.ChallengeRating
|
||||||
|
import com.majinnaibu.monstercards.data.enums.ChallengeRating.Companion.valueOfString
|
||||||
|
|
||||||
|
object ChallengeRatingConverter {
|
||||||
|
@JvmStatic
|
||||||
|
@TypeConverter
|
||||||
|
fun fromChallengeRating(challengeRating: ChallengeRating): String {
|
||||||
|
return challengeRating.stringValue
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@TypeConverter
|
||||||
|
fun challengeRatingFromStringValue(stringValue: String?): ChallengeRating {
|
||||||
|
return valueOfString(stringValue!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.majinnaibu.monstercards.data.converters;
|
|
||||||
|
|
||||||
import androidx.room.TypeConverter;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import com.majinnaibu.monstercards.models.Trait;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ListOfTraitsConverter {
|
|
||||||
@TypeConverter
|
|
||||||
public static String fromListOfTraits(List<Trait> traits) {
|
|
||||||
Gson gson = new Gson();
|
|
||||||
return gson.toJson(traits);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TypeConverter
|
|
||||||
public static List<Trait> listOfTraitsFromString(String string) {
|
|
||||||
Gson gson = new Gson();
|
|
||||||
Type setType = new TypeToken<ArrayList<Trait>>() {
|
|
||||||
}.getType();
|
|
||||||
return gson.fromJson(string, setType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.majinnaibu.monstercards.data.converters
|
||||||
|
|
||||||
|
import androidx.room.TypeConverter
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import com.google.gson.reflect.TypeToken
|
||||||
|
import com.majinnaibu.monstercards.models.Trait
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
object ListOfTraitsConverter {
|
||||||
|
@JvmStatic
|
||||||
|
@TypeConverter
|
||||||
|
fun fromListOfTraits(traits: List<Trait?>?): String {
|
||||||
|
val gson = Gson()
|
||||||
|
return gson.toJson(traits)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@TypeConverter
|
||||||
|
fun listOfTraitsFromString(string: String?): List<Trait> {
|
||||||
|
val gson = Gson()
|
||||||
|
val setType = object : TypeToken<ArrayList<Trait?>?>() {}.type
|
||||||
|
return gson.fromJson(string, setType)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package com.majinnaibu.monstercards.data.converters;
|
|
||||||
|
|
||||||
import androidx.room.TypeConverter;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import com.majinnaibu.monstercards.models.Language;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class SetOfLanguageConverter {
|
|
||||||
|
|
||||||
@TypeConverter
|
|
||||||
public static String fromSetOfLanguage(Set<Language> languages) {
|
|
||||||
Gson gson = new Gson();
|
|
||||||
return gson.toJson(languages);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TypeConverter
|
|
||||||
public static Set<Language> setOfLanguageFromString(String string) {
|
|
||||||
Gson gson = new Gson();
|
|
||||||
Type setType = new TypeToken<HashSet<Language>>() {
|
|
||||||
}.getType();
|
|
||||||
return gson.fromJson(string, setType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.majinnaibu.monstercards.data.converters
|
||||||
|
|
||||||
|
import androidx.room.TypeConverter
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import com.google.gson.reflect.TypeToken
|
||||||
|
import com.majinnaibu.monstercards.models.Language
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
object SetOfLanguageConverter {
|
||||||
|
@JvmStatic
|
||||||
|
@TypeConverter
|
||||||
|
fun fromSetOfLanguage(languages: Set<Language?>?): String {
|
||||||
|
val gson = Gson()
|
||||||
|
return gson.toJson(languages)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@TypeConverter
|
||||||
|
fun setOfLanguageFromString(string: String?): Set<Language> {
|
||||||
|
val gson = Gson()
|
||||||
|
val setType = object : TypeToken<HashSet<Language?>?>() {}.type
|
||||||
|
return gson.fromJson(string, setType)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package com.majinnaibu.monstercards.data.converters;
|
|
||||||
|
|
||||||
import androidx.room.TypeConverter;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import com.majinnaibu.monstercards.models.Skill;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class SetOfSkillConverter {
|
|
||||||
|
|
||||||
@TypeConverter
|
|
||||||
public static String fromSetOfSkill(Set<Skill> skills) {
|
|
||||||
Gson gson = new Gson();
|
|
||||||
return gson.toJson(skills);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TypeConverter
|
|
||||||
public static Set<Skill> setOfSkillFromString(String string) {
|
|
||||||
Gson gson = new Gson();
|
|
||||||
Type setType = new TypeToken<HashSet<Skill>>() {
|
|
||||||
}.getType();
|
|
||||||
return gson.fromJson(string, setType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.majinnaibu.monstercards.data.converters
|
||||||
|
|
||||||
|
import androidx.room.TypeConverter
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import com.google.gson.reflect.TypeToken
|
||||||
|
import com.majinnaibu.monstercards.models.Skill
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
object SetOfSkillConverter {
|
||||||
|
@JvmStatic
|
||||||
|
@TypeConverter
|
||||||
|
fun fromSetOfSkill(skills: Set<Skill?>?): String {
|
||||||
|
val gson = Gson()
|
||||||
|
return gson.toJson(skills)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@TypeConverter
|
||||||
|
fun setOfSkillFromString(string: String?): Set<Skill> {
|
||||||
|
val gson = Gson()
|
||||||
|
val setType = object : TypeToken<HashSet<Skill?>?>() {}.type
|
||||||
|
return gson.fromJson(string, setType)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.majinnaibu.monstercards.data.converters;
|
|
||||||
|
|
||||||
import androidx.room.TypeConverter;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class SetOfStringConverter {
|
|
||||||
|
|
||||||
@TypeConverter
|
|
||||||
public static String fromSetOfString(Set<String> strings) {
|
|
||||||
Gson gson = new Gson();
|
|
||||||
return gson.toJson(strings);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TypeConverter
|
|
||||||
public static Set<String> setOfStringFromString(String string) {
|
|
||||||
Gson gson = new Gson();
|
|
||||||
Type setType = new TypeToken<HashSet<String>>() {
|
|
||||||
}.getType();
|
|
||||||
return gson.fromJson(string, setType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.majinnaibu.monstercards.data.converters
|
||||||
|
|
||||||
|
import androidx.room.TypeConverter
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import com.google.gson.reflect.TypeToken
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
object SetOfStringConverter {
|
||||||
|
@JvmStatic
|
||||||
|
@TypeConverter
|
||||||
|
fun fromSetOfString(strings: Set<String?>?): String {
|
||||||
|
val gson = Gson()
|
||||||
|
return gson.toJson(strings)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@TypeConverter
|
||||||
|
fun setOfStringFromString(string: String?): Set<String> {
|
||||||
|
val gson = Gson()
|
||||||
|
val setType = object : TypeToken<HashSet<String?>?>() {}.type
|
||||||
|
return gson.fromJson(string, setType)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package com.majinnaibu.monstercards.data.converters;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.room.TypeConverter;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class UUIDConverter {
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@TypeConverter
|
|
||||||
public static String fromUUID(@NonNull UUID uuid) {
|
|
||||||
return uuid.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@TypeConverter
|
|
||||||
public static UUID uuidFromString(String string) {
|
|
||||||
return UUID.fromString(string);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.majinnaibu.monstercards.data.converters
|
||||||
|
|
||||||
|
import androidx.room.TypeConverter
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
object UUIDConverter {
|
||||||
|
@JvmStatic
|
||||||
|
@TypeConverter
|
||||||
|
fun fromUUID(uuid: UUID): String {
|
||||||
|
return uuid.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@TypeConverter
|
||||||
|
fun uuidFromString(string: String?): UUID {
|
||||||
|
return UUID.fromString(string)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user