1

I have a question about Moo (https://github.com/geoffreywiseman/Moo/) that I haven't been able to solve on my own. I have this class structure:

class Middle{
  private int id;
  private Upper upper;
  private List<Child> children;
  private List<Middle> brothers;
}

class Upper{
  private int id;
  private String name;
  private String lastname;
}

class Child{
  private int id;
  private String name;
}

and I want to translate them to:

class OutputMiddle{
  private int id;

  @Property(translation="Upper")
  private OutputUpper outputUpper;
  @CollectionProperty(itemTranslation = Upper.class)
  private List<OutputChild> outputChildren;
  private List<OutputMiddle> outputBrothers;
}

class OutputUpper{
  private int id;
  private String outputName;
}

class OutputChild{
  private int id;
  private String outputName;
}

What I don't know is:

  • Am I able to translate one attribute from one class to another attribute of another class?
  • And do the same but to a collection of objects?
  • And the same but to a collection of objects of the same class?

Why do I need this? Because I'm returning objects of the class "Middle" as JSON (or XML) and I need it to have an structure such as the "OutputMiddle", but I don't want to intervene the JSON after its creation and change the names of the nodes manually.

Thanks!

tobyink
  • 13,478
  • 1
  • 23
  • 35
  • I wish I'd seen this earlier, I would have answered it, or at least tried to clarify your question so that I could answer it. I'm not entirely certain that I understand the problem you were having. You should be able to do all the things that you wanted here, and it looks like the sort of thing I've used Moo for before. – Geoffrey Wiseman Mar 15 '13 at 18:25

1 Answers1

0

Try JMapper Framework, it's ease to use and require few configuration

Alessandro
  • 282
  • 3
  • 10