You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use Immutables to generate immutable DTOs. Everything works fine with DSL-JSON except List type field.
For example, i got this DTO
interface AbstractListDTO {
List getListField();
}
The generated file by Immutables look like
@CompiledJson
public final class ListDTO implements AbstractListDTO {
private final ImmutableList listField;
...
public ImmutableList getListField() {
return listField;
}
...
public static final class Builder
...
public final Builder listField(Iterable elements) {
this.listField = ImmutableList.builder();
return addAllListField(elements);
}
The generated _DslJsonConverter will miss that listField, even in Reflection mode too.
When i change the builder to accept ImmutableList instead of Iterable, it works fine and the _DslJsonConverter will contain that listField
public final Builder listField(ImmutableList elements) {
this.listField = ImmutableList.builder();
return addAllListField(elements);
}
Using Iterable make sense to me for a convenient builder. I wonder if DSL-JSON can support the builder with supertype in parameter like that?
The text was updated successfully, but these errors were encountered:
It would need to be extended to support that use case, but I guess it could support it.
btw. can you configure the immutable to generate both methods for such lists.. so to make both you and dsl-json happy? That seems like easier workaround atm :)
can you configure the immutable to generate both methods for such lists
Currently I found no way to do this with Immutables. In my example, I copy and modify the generated code by hand just for testing.
For now, I replace all List/Set fields to array and it still work because array have param ... on the builder 😄
Fortunately, this happen only in the api layer, and all of my DTOs use MapStruct for automaticaly mapping fields, then List/Set or array is not a big deal, nothing gonna change on the logic code :D
I use Immutables to generate immutable DTOs. Everything works fine with DSL-JSON except
List
type field.For example, i got this DTO
The generated file by Immutables look like
The generated
_DslJsonConverter
will miss thatlistField
, even in Reflection mode too.When i change the builder to accept
ImmutableList
instead ofIterable
, it works fine and the_DslJsonConverter
will contain thatlistField
Using
Iterable
make sense to me for a convenient builder. I wonder if DSL-JSON can support the builder with supertype in parameter like that?The text was updated successfully, but these errors were encountered: