Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reusing common DSL parts in different LambdaDslJsonBody objects #1796

Closed
tglaeser opened this issue May 13, 2024 · 5 comments
Closed

Reusing common DSL parts in different LambdaDslJsonBody objects #1796

tglaeser opened this issue May 13, 2024 · 5 comments
Labels
enhancement Indicates new feature requests

Comments

@tglaeser
Copy link

tglaeser commented May 13, 2024

I wonder if there is an elegant way to extract the common parts of the LambdaDslJsonBody and then use them instead of defining them twice?

Let's say we have

val y = newJsonObject {
    stringType("a", "foo")
    id("b", 0L)
    integerType("c", 0)
    booleanType("d", false)
    stringType("e", "bar")
}
val z = newJsonObject {
    stringType("a", "foo")
    id("b", 0L)
    integerType("c", 0)
    booleanType("d", false)
    nullValue("e")
}

All but one definition are identical, so I would rather do something like

val x = newJsonObject {
    stringType("a", "foo")
    id("b", 0L)
    integerType("c", 0)
    booleanType("d", false)
}
val y = extendJsonObject(x) {
    stringType("e", "bar")
}
val z = extendJsonObject(x) {
    nullValue("e")
}

What am I missing?

@rholshausen rholshausen added the enhancement Indicates new feature requests label May 21, 2024
@rholshausen
Copy link
Contributor

I've updated the DSL to support doing

    val x = newJsonObject {
      stringType("a", "foo")
      id("b", 0L)
      integerType("c", 0)
      booleanType("d", false)
    }
    val y = newJsonObject(x) {
      stringType("e", "bar")
    }
   val z = newJsonObject(x) {
      nullValue("e")
    }

@tglaeser
Copy link
Author

Excellent, thanks. With what version will this become available?

@rholshausen
Copy link
Contributor

4.6.10 has been released

@tglaeser
Copy link
Author

It seems that version 4.6.10 requires a JDK version greater than 11; by any chance, could you also release this change with a Java 11 compatible library version? Thanks.

rholshausen added a commit that referenced this issue Jun 20, 2024
@rholshausen
Copy link
Contributor

4.5.10 released with the change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Indicates new feature requests
Projects
None yet
Development

No branches or pull requests

2 participants