Skip to content

Commit

Permalink
rename EnumValue to CustomValue
Browse files Browse the repository at this point in the history
  • Loading branch information
barbulescu committed Jan 6, 2024
1 parent f037298 commit 972d641
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ interface JsonDslSerializer {
}

/**
* Used for serialization of enums with Java name different from serialized value.
* Used for custom serialization where toString method does not provide the correct value.
*/
interface EnumValue<T> {
interface CustomValue<T> {
val value: T
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class SimpleJsonSerializer : JsonDslSerializer {
buf.append(']')
}

is EnumValue<*> -> write(buf, indent, indentStep, pretty, obj.value)
is CustomValue<*> -> write(buf, indent, indentStep, pretty, obj.value)

else -> {
// fallback to just treating everything else as a String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.jillesvangurp.jsondsl
import io.kotest.matchers.shouldBe
import kotlin.test.Test

enum class GradeEnum(override val value: Int) : EnumValue<Int> {
enum class GradeEnum(override val value: Int) : CustomValue<Int> {
A(1),
B(2)
}
Expand All @@ -12,7 +12,7 @@ class DslWithEnum : JsonDsl() {
var grade by property<GradeEnum>()
}

class EnumValueTest {
class CustomValueTest {

@Test
fun enumSerialization() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.jillesvangurp.searchdsls.querydsl

import com.jillesvangurp.jsondsl.EnumValue
import com.jillesvangurp.jsondsl.CustomValue
import com.jillesvangurp.jsondsl.JsonDsl

enum class Conflict(override val value: String) : EnumValue<String> {
enum class Conflict(override val value: String) : CustomValue<String> {
ABORT("abort"),
PROCEED("proceed");
}
Expand Down Expand Up @@ -42,19 +42,19 @@ class ReindexDestinationDSL : JsonDsl() {
var pipeline: String by property()
}

enum class ReindexVersionType(override val value: String) : EnumValue<String> {
enum class ReindexVersionType(override val value: String) : CustomValue<String> {
INTERNAL("internal"),
EXTERNAL("external"),
EXTERNAL_GT("external_gt"),
EXTERNAL_GTE("external_gte")
}

enum class ReindexOperationType(override val value: String) : EnumValue<String> {
enum class ReindexOperationType(override val value: String) : CustomValue<String> {
INDEX("index"),
CREATE("create")
}

enum class Language(override val value: String) : EnumValue<String> {
enum class Language(override val value: String) : CustomValue<String> {
PAINLESS("painless"),
EXPRESSION("expression"),
MUSTACHE("mustache"),
Expand Down

0 comments on commit 972d641

Please sign in to comment.