-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…d convert them to Kotlin.
- Loading branch information
1 parent
5d89dec
commit 7f249c4
Showing
29 changed files
with
206 additions
and
191 deletions.
There are no files selected for viewing
165 changes: 165 additions & 0 deletions
165
kgCommon/src/main/kotlin/ru/klavogonki/common/StandardDictionary.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
package ru.klavogonki.common | ||
|
||
/** | ||
* Copyright 2014 [Dmitriy Popov](mailto:[email protected]). | ||
* $HeadURL$ | ||
* $Author$ | ||
* $Revision$ | ||
* $Date:: $ | ||
* <br></br> | ||
* <br></br> | ||
* Энум с названиями стандартных словарей (режимов), как они используются в AJAX-API. | ||
*/ | ||
@SuppressWarnings("MagicNumber") | ||
enum class StandardDictionary( | ||
|
||
/** | ||
* Имя в API клавогонок. Все буквы в нижнем регистре. | ||
*/ | ||
@JvmField val klavogonkiName: String, | ||
|
||
/** | ||
* Русское название словаря для отображения. | ||
*/ | ||
@JvmField val displayName: String, | ||
|
||
/** | ||
* Русское название словаря для отображения, в предложном падеже. | ||
*/ | ||
@JvmField val displayNamePrepositional: String, | ||
|
||
/** | ||
* Цвет стандартного словаря в формате #123456 | ||
*/ | ||
@JvmField val color: String, | ||
|
||
/** | ||
* Страница стандартного словаря в [википедии клавогонок](http://klavogonki.ru/wiki/). | ||
*/ | ||
@JvmField val wikiPageUrl: String, | ||
|
||
/** | ||
* Тип текста словаря. | ||
* Для нестандартных словарей будет равен идентификатору словаря. | ||
*/ | ||
@JvmField val textType: Int | ||
) { | ||
/** | ||
* Обычный. | ||
*/ | ||
normal( | ||
klavogonkiName = "normal", | ||
displayName = "Обычный", | ||
displayNamePrepositional = "Обычном", | ||
color = "#333333", | ||
wikiPageUrl = Wiki.getUrl("%D0%9E%D0%B1%D1%8B%D1%87%D0%BD%D1%8B%D0%B9"), | ||
textType = 0 | ||
), | ||
|
||
/** | ||
* Безошибочный. | ||
*/ | ||
noerror( | ||
klavogonkiName = "noerror", | ||
displayName = "Безошибочный", | ||
displayNamePrepositional = "Безошибочном", | ||
color = "#4692AA", | ||
wikiPageUrl = Wiki.getUrl("%D0%91%D0%B5%D0%B7%D0%BE%D1%88%D0%B8%D0%B1%D0%BE%D1%87%D0%BD%D1%8B%D0%B9"), | ||
textType = 0 | ||
), | ||
|
||
/** | ||
* Буквы. | ||
*/ | ||
chars( | ||
klavogonkiName = "chars", | ||
displayName = "Буквы", | ||
displayNamePrepositional = "Буквах", | ||
color = "#B55900", | ||
wikiPageUrl = Wiki.getUrl("%D0%91%D1%83%D0%BA%D0%B2%D1%8B"), | ||
textType = -4 | ||
), | ||
|
||
/** | ||
* Марафон. | ||
*/ | ||
marathon( | ||
klavogonkiName = "marathon", | ||
displayName = "Марафон", | ||
displayNamePrepositional = "Марафоне", | ||
color = "#D43E68", | ||
wikiPageUrl = Wiki.getUrl("%D0%9C%D0%B0%D1%80%D0%B0%D1%84%D0%BE%D0%BD"), | ||
textType = 0 | ||
), | ||
|
||
/** | ||
* Абракадабра. | ||
*/ | ||
abra( | ||
klavogonkiName = "abra", | ||
displayName = "Абракадабра", | ||
displayNamePrepositional = "Абракадабре", | ||
color = "#3D4856", | ||
wikiPageUrl = Wiki.getUrl("%D0%90%D0%B1%D1%80%D0%B0%D0%BA%D0%B0%D0%B4%D0%B0%D0%B1%D1%80%D0%B0"), | ||
textType = -1 | ||
), | ||
|
||
/** | ||
* Яндекс.Рефераты. | ||
*/ | ||
referats( | ||
klavogonkiName = "referats", | ||
displayName = "Яндекс.Рефераты", | ||
displayNamePrepositional = "Яндекс.Рефератах", | ||
color = "#698725", | ||
wikiPageUrl = Wiki.getUrl("%D0%AF%D0%BD%D0%B4%D0%B5%D0%BA%D1%81.%D0%A0%D0%B5%D1%84%D0%B5%D1%80%D0%B0%D1%82%D1%8B"), | ||
textType = -3 | ||
), | ||
|
||
/** | ||
* Цифры. | ||
*/ | ||
digits( | ||
klavogonkiName = "digits", | ||
displayName = "Цифры", | ||
displayNamePrepositional = "Цифрах", | ||
color = "#777777", | ||
wikiPageUrl = Wiki.getUrl("%D0%A6%D0%B8%D1%84%D1%80%D1%8B"), | ||
textType = -2 | ||
), | ||
|
||
/** | ||
* Спринт. | ||
*/ | ||
sprint( | ||
klavogonkiName = "sprint", | ||
displayName = "Спринт", | ||
displayNamePrepositional = "Спринте", | ||
color = "#833F3A", | ||
wikiPageUrl = Wiki.getUrl("%D0%A1%D0%BF%D1%80%D0%B8%D0%BD%D1%82"), | ||
textType = 0 | ||
), | ||
; | ||
|
||
companion object { | ||
|
||
@JvmStatic | ||
fun isValidStandardDictionaryCode(code: String) = | ||
entries.any { it.klavogonkiName == code } | ||
|
||
@JvmStatic | ||
fun getByKlavogonkiName(code: String): StandardDictionary { | ||
val values = entries.filter { it.klavogonkiName == code } | ||
|
||
check(values.isNotEmpty()) { | ||
"No standard dictionary for code = \"$code\"." | ||
} | ||
|
||
check(values.size == 1) { | ||
"More than one standard dictionary for code = \"$code\"." | ||
} | ||
|
||
return values[0] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package ru.klavogonki.common | ||
|
||
object Wiki { | ||
private const val WIKI_BASE_URL = "https://klavogonki.ru/wiki/" | ||
|
||
fun getUrl(pageName: String) = | ||
WIKI_BASE_URL + pageName.trim() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package ru.klavogonki.kgparser; | ||
|
||
import ru.klavogonki.common.StandardDictionary; | ||
|
||
import java.util.Arrays; | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.