Created
January 25, 2014 09:43
-
-
Save sjaakd/8614089 to your computer and use it in GitHub Desktop.
Custom Mapper with same simpleName on different namespace (package)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package com.mycompany.mapstruct.p2; | |
/** | |
* | |
* @author sjaak | |
*/ | |
public class Helper { | |
public String toMyString(Integer source) { | |
return source.toString(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mycompany.mapstruct; | |
public class Source { | |
private String foo1; | |
private Integer foo2; | |
public String getFoo1() { | |
return foo1; | |
} | |
public void setFoo1( String foo1 ) { | |
this.foo1 = foo1; | |
} | |
public Integer getFoo2() { | |
return foo2; | |
} | |
public void setFoo2( Integer foo2 ) { | |
this.foo2 = foo2; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mycompany.mapstruct; | |
import com.mycompany.mapstruct.p1.Helper; | |
import org.mapstruct.Mapper; | |
@Mapper( uses = { Helper.class, com.mycompany.mapstruct.p2.Helper.class } ) | |
public interface SourceTargetMapper { | |
Target transform(Source survey); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mycompany.mapstruct; | |
public class Target { | |
private Integer foo1; | |
private String foo2; | |
public Integer getFoo1() { | |
return foo1; | |
} | |
public void setFoo1( Integer foo1 ) { | |
this.foo1 = foo1; | |
} | |
public String getFoo2() { | |
return foo2; | |
} | |
public void setFoo2( String foo2 ) { | |
this.foo2 = foo2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment