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

Generate the builder when there is a nested class. #24

Open
2 tasks
engtecmat opened this issue Jun 10, 2022 · 1 comment
Open
2 tasks

Generate the builder when there is a nested class. #24

engtecmat opened this issue Jun 10, 2022 · 1 comment
Assignees
Labels
bug Something isn't working feature-request Suggest an idea for this project

Comments

@engtecmat
Copy link

engtecmat commented Jun 10, 2022

Describe the feature

Hi @zhezhangz,

I'm coming back, again. Thanks for your development of the invaluable features, such as 'list' and 'stream', and so on. However, I like them so much.

I'm writing to ask if it is possible for the builder can be generated even in a nested class. I thought you might think we seldom get this usage, but you know, we will.

Use Case

@Getter
@Setter
public class Order {
  private String orderNo;
  private List<OrderLine> lines;

  @Getter
  @Setter
  public static class OrderLine {
    private String name;
    private BigDecimal price;
  }
}
@Override
  protected void populate(OrderRequest model, ModelCache modelCache) {
    ReflectionUtil.setField(model, "com.project.template.api.OrderRequest#orderNo", new StringRandomizer(6, 20, 3).next());
    ReflectionUtil.setField(model, "com.project.template.api.OrderRequest#lines", new ListRandomizer<>(new CustomTypeRandomizer<>(new com.project.template.api.OrderRequest.OrderLineModeler(), modelCache), 1, 20).next());
  }
error: cannot find symbol
    ReflectionUtil.setField(model, "com.project.template.api.OrderRequest#lines", new ListRandomizer<>(new CustomTypeRandomizer<>(new com.project.template.api.OrderRequest.OrderLineModeler(), modelCache), 1, 20).next());
                                                                                                                                                                           ^
  symbol:   class OrderLineModeler
  location: class OrderRequest

Possible Solution / Additional Notes

No response

Acknowledgements

  • I may be able to implement this feature
  • This feature will introduce some breaking changes

EasyModeling Version

0.1.3

@engtecmat engtecmat added the feature-request Suggest an idea for this project label Jun 10, 2022
@zhezhangz
Copy link
Collaborator

Hey Evan,
Thank you so much for the feedback! The nested class as field types is an important feature that I have missed.
I was thinking of handling that without changing the current framework too much, (while enjoying the summer with my family😜). However, I feel like it's not very easy to find a way for my poor design from the very beginning.
Anyways, I will try to figure it out, or at least temporarily ignore the population of fields with inner classes as their types to avoid compiling errors.

@zhezhangz zhezhangz self-assigned this Jun 18, 2022
@zhezhangz zhezhangz added the bug Something isn't working label Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature-request Suggest an idea for this project
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants