We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I cannot map an interface to a DTO The interface describing my beans
public interface Person { String getNom(); String getPrenom(); }
The implementation of my interface
public class PersonImpl implements Person { private String nom; private String prenom; public PersonImpl() { } public PersonImpl(String nom, String prenom) { this.nom = nom; this.prenom = prenom; } public String getNom() { return this.nom; } public String getPrenom() { return this.prenom; } }
The Dto Bean
public class PersonDto { private String nom; private String prenom; public PersonDto() { } public void setNom(String nom) { this.nom = nom; } public void setPrenom(String prenom) { this.prenom = prenom; } public String getNom() { return this.nom; } public String getPrenom() { return this.prenom; } }
The mapper
@Mapper public interface PersonMapper { PersonDto toDto(Person patient); }
The Unit test fails
public class PersonMapperTest { public static final String NOM = "nom"; public static final String PRENOM = "prenom"; private PersonMapper personMapper = Selma.builder(PersonMapper.class).build(); @Test public void shouldMap() { Person person = new PersonImpl(NOM, PRENOM); PersonDto personDto = personMapper.toDto(person); assertThat(personDto.getNom()).isEqualTo(NOM); assertThat(personDto.getPrenom()).isEqualTo(PRENOM); } }
The impacted selma code is the isGetter method of MethodWrapper class. If you remove the test on Modifier.ABSTRACT all works fine.
public class MethodWrapper { ... public boolean isGetter() { boolean res = false; if (hasNoParameter() && method.getReturnType().getKind() != TypeKind.VOID && method.getModifiers().contains(Modifier.PUBLIC) && !method.getModifiers().contains(Modifier.ABSTRACT) && !method.getModifiers().contains(Modifier.STATIC)) { Matcher getterMatcher = GETTER_PATTERN.matcher(method.getSimpleName()); res = getterMatcher.matches(); if (res) { fieldName = getterMatcher.group(2); } } return res; } }
We were confronted to this problem using spring data mongoDb projections mapping to rest dto beans.
demo.zip
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I cannot map an interface to a DTO
The interface describing my beans
The implementation of my interface
The Dto Bean
The mapper
The Unit test fails
The impacted selma code is the isGetter method of MethodWrapper class.
If you remove the test on Modifier.ABSTRACT all works fine.
We were confronted to this problem using spring data mongoDb projections mapping to rest dto beans.
demo.zip
The text was updated successfully, but these errors were encountered: