8

I've been doing a lot of integration towards SOAP services lately. Say I get this object from the SOAP service:

public class ObjectA{
  private String someString;
  private Integer someInteger;
}

For this object I want to make my own representation "ObjectB" which is basically the same but I dont want to expose objects from the WSDL outside my integration artifact.

So then I map between ObjectA and ObjectB. But this is a lot of manual work especially if the objects have many fields. Are there any smart ways in IntelliJ to generate a mapping between two objects?

Thanks

oyvind.s
  • 232
  • 1
  • 15

1 Answers1

3

You can use the Dozer framework, which is an Object-to-Obejct mapper.

By default it will map by convention, but this can be overridden/customized with a mapping file.

Details here: http://dozer.sourceforge.net/

I've used it before to map use-case specific service payload objects onto re-usable domain objects.

Edit:

MapStruct is a more modern mapping framework. It uses compile-time generation:

Jasper Blues
  • 28,258
  • 22
  • 102
  • 185
  • It's very slow, so unless you know speed won't be an issue, find something better or do it by hand. – estani Apr 26 '17 at 15:57