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

Access.Level NONE for fields in Json #194

Closed
prasannajoshi2121 opened this issue Oct 26, 2020 · 4 comments
Closed

Access.Level NONE for fields in Json #194

prasannajoshi2121 opened this issue Oct 26, 2020 · 4 comments

Comments

@prasannajoshi2121
Copy link

Hi @zapov ,

#177

similar to this issue , if we dont have Setter method available on fields ,then how should we populate that value from Json ??
the solution in above issue was for using @nonnull annotation with Access.Level NONE for Collection Types which we discussed but it seems like not working for normal fields like String , Object and all reference types .

My take is to use public constructor to populate those values instead of breaking encapsulation , what do you think ? what should be best way to do that ??

Below is Pojo class which is having issue. let me know if you need entire reproducible example.

@AllArgsConstructor
@NoArgsConstructor
@tostring
@getter
@Setter
@CompiledJson
public class PrivateSetterNonNull {

@JsonProperty(value = "test_string")
@nonnull
@Setter(AccessLevel.NONE)
private String testString;
}

@zapov
Copy link
Member

zapov commented Oct 26, 2020

If there is appropriate ctor it will surely use that. There are many usages of that in examples and tests.
Maybe no-arg ctor is creating problems

@prasannajoshi2121
Copy link
Author

well the problem is DSL compilation is trying to find matching constructor before Lombok generating classes itself hence DSL compiler assume that there will be always NO-ARG ctor only even if we have @AllArgsConstructor annotation.

So generated convertor class is having no-arg ctor as initialisation mechanism and its ignoring Lombok generated All-arg Constructor reason why i am facing above issue.

Note : If i am defining matching All-arg ctor in my Pojo then i am not facing any issue. Let me know if we can discuss this and try to find some solution if possible.

@zapov
Copy link
Member

zapov commented Oct 26, 2020

Ugh... I don't think there is much to be done here ;(
The only thing which comes to mind is that you try to make this a two pass over the source/classes so that dsl-json picks up the expected class objects (if that is even possible)

I think this question is more for Lombok community on how to setup pipeline so that everything is visible for the next annotation processor.

@prasannajoshi2121
Copy link
Author

not sure if there is any ordering for. annotation processor , anyways i can leave with it as of now but lets see if we can find some better solution , i will let you know if found anything. thanks as usual for providing quick support :). closing this as of now

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

No branches or pull requests

2 participants