Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
ikovalyov committed Jun 29, 2024
1 parent 0f72b89 commit 02fd7d4
Show file tree
Hide file tree
Showing 61 changed files with 836 additions and 974 deletions.
20 changes: 10 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ kotlin {
implementation(kotlin("stdlib-js"))
implementation(
project.dependencies.enforcedPlatform(
"org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:1.0.0-pre.763"
)
"org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:1.0.0-pre.763",
),
)
implementation("org.jetbrains.kotlin-wrappers:kotlin-react")
implementation("org.jetbrains.kotlin-wrappers:kotlin-react-dom")
Expand Down Expand Up @@ -131,8 +131,8 @@ kotlin {
configurations["kapt"].dependencies.addAll(
listOf(
project.dependencies.create("io.micronaut:micronaut-inject-java:3.10.4"),
project.dependencies.create("info.picocli:picocli-codegen:4.7.6")
)
project.dependencies.create("info.picocli:picocli-codegen:4.7.6"),
),
)
if (System.getProperty("os.name").lowercase(Locale.getDefault()).contains("mac")) {
implementation("io.micronaut:micronaut-runtime-osx")
Expand All @@ -146,8 +146,8 @@ kotlin {
configurations["kaptTest"].dependencies.addAll(
listOf(
project.dependencies.create("io.micronaut:micronaut-inject-java:3.10.4"),
project.dependencies.create("info.picocli:picocli-codegen:4.7.6")
)
project.dependencies.create("info.picocli:picocli-codegen:4.7.6"),
),
)

implementation(kotlin("test-junit5"))
Expand Down Expand Up @@ -212,17 +212,17 @@ spotless {
.editorConfigOverride(
mapOf(
"max_line_length" to "256",
"insert_final_newline" to "true"
)
"insert_final_newline" to "true",
),
)
}
kotlinGradle {
ktlint("1.3.0")
.editorConfigOverride(
mapOf(
"max_line_length" to "256",
"insert_final_newline" to "true"
)
"insert_final_newline" to "true",
),
)
}
}
308 changes: 152 additions & 156 deletions src/commonMain/kotlin/com.github.ikovalyov.model/Article.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,162 +26,158 @@ data class Article(
val meta: List<String>?,
val template: Template?, // Template uuid
val userList: List<User>,
val templateList: List<Template>
val templateList: List<Template>,
) : IEditable {
override fun getMetadata(): List<IEditable.EditableMetadata<*, Article>> {
return listOf(
IEditable.EditableMetadata(
fieldType = IEditable.FieldType.Id,
readOnly = true,
serialize = {
it.toString()
},
deserialize = {
uuidFrom(it)
},
update = {
copy(id = it)
},
get = {
id
},
fieldName = "Id",
predefinedList = null
),
IEditable.EditableMetadata(
fieldType = IEditable.FieldType.Name,
readOnly = false,
serialize = {
it
},
deserialize = {
it
},
update = {
copy(name = it)
},
get = {
name
},
fieldName = "Name",
predefinedList = null
),
IEditable.EditableMetadata(
fieldType = IEditable.FieldType.Abstract,
readOnly = false,
serialize = {
it
},
deserialize = {
it
},
update = {
copy(abstract = it)
},
get = {
abstract
},
fieldName = "Abstract",
predefinedList = null
),
IEditable.EditableMetadata(
fieldType = IEditable.FieldType.Body,
readOnly = false,
serialize = {
it
},
deserialize = {
it
},
update = {
copy(body = it)
},
get = {
body
},
fieldName = "Body",
predefinedList = null
),
IEditable.EditableMetadata(
fieldType = IEditable.FieldType.Author,
readOnly = false,
serialize = {
it.id.toString()
},
deserialize = { uuid ->
userList.first {
it.id.toString() == uuid
}
},
update = {
copy(author = it)
},
get = {
author
},
fieldName = "Author",
predefinedList = userList
),
IEditable.EditableMetadata(
fieldType = IEditable.FieldType.Tags,
readOnly = false,
serialize = {
it.joinToString(separator = ",")
},
deserialize = {
it.split(",")
},
update = {
copy(tags = it)
},
get = {
tags
},
fieldName = "Tags",
predefinedList = null
),
IEditable.EditableMetadata(
fieldType = IEditable.FieldType.StringListFiledType,
readOnly = false,
serialize = {
it.joinToString(separator = ",")
},
deserialize = {
it.split(",")
},
update = {
copy(meta = it)
},
get = {
meta
},
fieldName = "Meta",
predefinedList = null
),
IEditable.EditableMetadata(
fieldType = IEditable.FieldType.Template,
readOnly = false,
serialize = {
it.id.toString()
},
deserialize = { uuid ->
templateList.first {
it.id.toString() == uuid
}
},
update = {
copy(template = it)
},
get = {
template
},
fieldName = "Template",
predefinedList = templateList
)
)
}
override fun getMetadata(): List<IEditable.EditableMetadata<*, Article>> = listOf(
IEditable.EditableMetadata(
fieldType = IEditable.FieldType.Id,
readOnly = true,
serialize = {
it.toString()
},
deserialize = {
uuidFrom(it)
},
update = {
copy(id = it)
},
get = {
id
},
fieldName = "Id",
predefinedList = null,
),
IEditable.EditableMetadata(
fieldType = IEditable.FieldType.Name,
readOnly = false,
serialize = {
it
},
deserialize = {
it
},
update = {
copy(name = it)
},
get = {
name
},
fieldName = "Name",
predefinedList = null,
),
IEditable.EditableMetadata(
fieldType = IEditable.FieldType.Abstract,
readOnly = false,
serialize = {
it
},
deserialize = {
it
},
update = {
copy(abstract = it)
},
get = {
abstract
},
fieldName = "Abstract",
predefinedList = null,
),
IEditable.EditableMetadata(
fieldType = IEditable.FieldType.Body,
readOnly = false,
serialize = {
it
},
deserialize = {
it
},
update = {
copy(body = it)
},
get = {
body
},
fieldName = "Body",
predefinedList = null,
),
IEditable.EditableMetadata(
fieldType = IEditable.FieldType.Author,
readOnly = false,
serialize = {
it.id.toString()
},
deserialize = { uuid ->
userList.first {
it.id.toString() == uuid
}
},
update = {
copy(author = it)
},
get = {
author
},
fieldName = "Author",
predefinedList = userList,
),
IEditable.EditableMetadata(
fieldType = IEditable.FieldType.Tags,
readOnly = false,
serialize = {
it.joinToString(separator = ",")
},
deserialize = {
it.split(",")
},
update = {
copy(tags = it)
},
get = {
tags
},
fieldName = "Tags",
predefinedList = null,
),
IEditable.EditableMetadata(
fieldType = IEditable.FieldType.StringListFiledType,
readOnly = false,
serialize = {
it.joinToString(separator = ",")
},
deserialize = {
it.split(",")
},
update = {
copy(meta = it)
},
get = {
meta
},
fieldName = "Meta",
predefinedList = null,
),
IEditable.EditableMetadata(
fieldType = IEditable.FieldType.Template,
readOnly = false,
serialize = {
it.id.toString()
},
deserialize = { uuid ->
templateList.first {
it.id.toString() == uuid
}
},
update = {
copy(template = it)
},
get = {
template
},
fieldName = "Template",
predefinedList = templateList,
),
)

override fun serialize(): String {
return Json.encodeToString(this)
}
override fun serialize(): String = Json.encodeToString(this)
}
Loading

0 comments on commit 02fd7d4

Please sign in to comment.