From 8239c58aeb83d177fdee09f982d4e43bb14b821c Mon Sep 17 00:00:00 2001 From: dmitry-weirdo Date: Mon, 25 Nov 2024 22:46:43 +0100 Subject: [PATCH] feat: #81 #102 Move `NonStandardDictionaryType` to `kg-common` and convert it to Kotlin. --- .../ru/klavogonki/common/DictionaryMode.kt | 2 +- .../common/NonStandardDictionaryType.kt | 41 +++++++++++++++++++ .../kgparser/NonStandardDictionaryType.java | 39 ------------------ .../entity/PlayerVocabularyStatsEntity.java | 6 +-- .../mapper/PlayerVocabularyStatsMapper.java | 2 +- 5 files changed, 46 insertions(+), 44 deletions(-) create mode 100644 kgCommon/src/main/kotlin/ru/klavogonki/common/NonStandardDictionaryType.kt delete mode 100644 kgparserSrv/src/main/java/ru/klavogonki/kgparser/NonStandardDictionaryType.java diff --git a/kgCommon/src/main/kotlin/ru/klavogonki/common/DictionaryMode.kt b/kgCommon/src/main/kotlin/ru/klavogonki/common/DictionaryMode.kt index 82a5ec2a..5f3ff116 100644 --- a/kgCommon/src/main/kotlin/ru/klavogonki/common/DictionaryMode.kt +++ b/kgCommon/src/main/kotlin/ru/klavogonki/common/DictionaryMode.kt @@ -7,7 +7,7 @@ enum class DictionaryMode( /** * Имя в API клавогонок. Все буквы в нижнем регистре. */ - @JvmField val klavogonkiName: String, + @JvmField val klavogonkiName: String ) { normal("normal"), diff --git a/kgCommon/src/main/kotlin/ru/klavogonki/common/NonStandardDictionaryType.kt b/kgCommon/src/main/kotlin/ru/klavogonki/common/NonStandardDictionaryType.kt new file mode 100644 index 00000000..4e81f2b9 --- /dev/null +++ b/kgCommon/src/main/kotlin/ru/klavogonki/common/NonStandardDictionaryType.kt @@ -0,0 +1,41 @@ +package ru.klavogonki.common + +/** + * Тип нестандартного словаря. + */ +enum class NonStandardDictionaryType( + /** + * Имя в API клавогонок. Все буквы в нижнем регистре. + */ + @JvmField val klavogonkiName: String +) { + /** + * Слова. + */ + words("words"), + + /** + * Фразы. + */ + phrases("phrases"), + + /** + * Тексты. + */ + texts("texts"), + + /** + * URL. + */ + url("url"), + + /** + * Книга. + */ + book("book"), + + /** + * Генератор. + */ + generator("generator"), +} \ No newline at end of file diff --git a/kgparserSrv/src/main/java/ru/klavogonki/kgparser/NonStandardDictionaryType.java b/kgparserSrv/src/main/java/ru/klavogonki/kgparser/NonStandardDictionaryType.java deleted file mode 100644 index e4304d0a..00000000 --- a/kgparserSrv/src/main/java/ru/klavogonki/kgparser/NonStandardDictionaryType.java +++ /dev/null @@ -1,39 +0,0 @@ -package ru.klavogonki.kgparser; - -/** - * Тип нестандартного словаря - */ -public enum NonStandardDictionaryType { - - /** - * Слова. - */ - words, - - /** - * Фразы. - */ - phrases, - - /** - * Тексты. - */ - texts, - - /** - * URL. - */ - url, - - /** - * Книга. - */ - book, - - /** - * Генератор. - */ - generator, - - ; -} diff --git a/kgstatsSrv/src/main/java/ru/klavogonki/statistics/entity/PlayerVocabularyStatsEntity.java b/kgstatsSrv/src/main/java/ru/klavogonki/statistics/entity/PlayerVocabularyStatsEntity.java index 2913ff38..28a0f8a4 100644 --- a/kgstatsSrv/src/main/java/ru/klavogonki/statistics/entity/PlayerVocabularyStatsEntity.java +++ b/kgstatsSrv/src/main/java/ru/klavogonki/statistics/entity/PlayerVocabularyStatsEntity.java @@ -2,7 +2,7 @@ import lombok.Data; import ru.klavogonki.common.DictionaryMode; -import ru.klavogonki.kgparser.NonStandardDictionaryType; +import ru.klavogonki.common.NonStandardDictionaryType; import javax.persistence.Entity; import javax.persistence.EnumType; @@ -49,7 +49,7 @@ public class PlayerVocabularyStatsEntity implements Serializable { private String vocabularyName; - @Enumerated(EnumType.STRING) + @Enumerated(EnumType.STRING) // todo: save using the klavogonikiName field, NOT the enum itself (to save compatibility with the old databases) private NonStandardDictionaryType vocabularyType; private Integer vocabularySymbols; // for non-standard dictionaries only @@ -67,7 +67,7 @@ public class PlayerVocabularyStatsEntity implements Serializable { * * @see DictionaryMode#getDictionaryMode */ - @Enumerated(EnumType.STRING) // todo: save using the klavogonikiName field, NOT the enum itself + @Enumerated(EnumType.STRING) // todo: save using the klavogonikiName field, NOT the enum itself (to save compatibility with the old databases) private DictionaryMode vocabularyMode; /** diff --git a/kgstatsSrv/src/main/java/ru/klavogonki/statistics/mapper/PlayerVocabularyStatsMapper.java b/kgstatsSrv/src/main/java/ru/klavogonki/statistics/mapper/PlayerVocabularyStatsMapper.java index f74c890e..1da14ed3 100644 --- a/kgstatsSrv/src/main/java/ru/klavogonki/statistics/mapper/PlayerVocabularyStatsMapper.java +++ b/kgstatsSrv/src/main/java/ru/klavogonki/statistics/mapper/PlayerVocabularyStatsMapper.java @@ -8,7 +8,7 @@ import org.mapstruct.ValueMapping; import org.mapstruct.ValueMappings; import ru.klavogonki.common.DictionaryMode; -import ru.klavogonki.kgparser.NonStandardDictionaryType; +import ru.klavogonki.common.NonStandardDictionaryType; import ru.klavogonki.openapi.model.GetStatsOverviewGameType; import ru.klavogonki.openapi.model.GetStatsOverviewResponse; import ru.klavogonki.openapi.model.NonStandardVocabularyType;