Skip to content

Instantly share code, notes, and snippets.

@sjaakd
Created January 25, 2014 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjaakd/8614089 to your computer and use it in GitHub Desktop.
Save sjaakd/8614089 to your computer and use it in GitHub Desktop.
Custom Mapper with same simpleName on different namespace (package)
/*
* 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();
}
}
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;
}
}
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);
}
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