bean-mapping: Dozer 7.0.0 vs MapStruct 1.6.3 module (basic/nested/collection/null handling, silent-failure pitfalls, records, lazy getters, parity test, compile-failure demos, JMH benchmark), 14 contract tests
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b6ZEVHGaYy15HAxRzy
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
a714780bca
commit
91f0757259
@@ -0,0 +1,137 @@
|
||||
package com.ankurm.beanmapping.mapstruct;
|
||||
|
||||
import com.ankurm.beanmapping.model.ProfileDTO;
|
||||
import com.ankurm.beanmapping.model.ProfileEntity;
|
||||
import com.ankurm.beanmapping.model.TagEntity;
|
||||
import com.ankurm.beanmapping.model.UserDTO;
|
||||
import com.ankurm.beanmapping.model.UserEntity;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.annotation.processing.Generated;
|
||||
|
||||
@Generated(
|
||||
value = "org.mapstruct.ap.MappingProcessor",
|
||||
date = "2026-12-01T08:07:17+0530",
|
||||
comments = "version: 1.6.3, compiler: javac, environment: Java 25.0.5.1 (Eclipse Adoptium)"
|
||||
)
|
||||
public class UserMapperImpl implements UserMapper {
|
||||
|
||||
@Override
|
||||
public UserEntity toEntity(UserDTO dto) {
|
||||
if ( dto == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
UserEntity userEntity = new UserEntity();
|
||||
|
||||
userEntity.setEmailAddress( dto.getEmail() );
|
||||
userEntity.setId( dto.getId() );
|
||||
userEntity.setUsername( dto.getUsername() );
|
||||
userEntity.setProfile( toEntity( dto.getProfile() ) );
|
||||
userEntity.setTags( stringListToTagEntityList( dto.getTags() ) );
|
||||
|
||||
return userEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDTO toDto(UserEntity entity) {
|
||||
if ( entity == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
UserDTO userDTO = new UserDTO();
|
||||
|
||||
userDTO.setEmail( entity.getEmailAddress() );
|
||||
userDTO.setId( entity.getId() );
|
||||
userDTO.setUsername( entity.getUsername() );
|
||||
userDTO.setProfile( toDto( entity.getProfile() ) );
|
||||
userDTO.setTags( tagEntityListToStringList( entity.getTags() ) );
|
||||
|
||||
return userDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfileEntity toEntity(ProfileDTO profile) {
|
||||
if ( profile == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ProfileEntity profileEntity = new ProfileEntity();
|
||||
|
||||
profileEntity.setFirstName( profile.getFirstName() );
|
||||
profileEntity.setLastName( profile.getLastName() );
|
||||
|
||||
return profileEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfileDTO toDto(ProfileEntity profile) {
|
||||
if ( profile == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ProfileDTO profileDTO = new ProfileDTO();
|
||||
|
||||
profileDTO.setFirstName( profile.getFirstName() );
|
||||
profileDTO.setLastName( profile.getLastName() );
|
||||
|
||||
return profileDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(UserEntity target, UserDTO source) {
|
||||
if ( source == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( source.getEmail() != null ) {
|
||||
target.setEmailAddress( source.getEmail() );
|
||||
}
|
||||
target.setId( source.getId() );
|
||||
if ( source.getUsername() != null ) {
|
||||
target.setUsername( source.getUsername() );
|
||||
}
|
||||
if ( source.getProfile() != null ) {
|
||||
target.setProfile( toEntity( source.getProfile() ) );
|
||||
}
|
||||
if ( target.getTags() != null ) {
|
||||
List<TagEntity> list = stringListToTagEntityList( source.getTags() );
|
||||
if ( list != null ) {
|
||||
target.getTags().clear();
|
||||
target.getTags().addAll( list );
|
||||
}
|
||||
}
|
||||
else {
|
||||
List<TagEntity> list = stringListToTagEntityList( source.getTags() );
|
||||
if ( list != null ) {
|
||||
target.setTags( list );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected List<TagEntity> stringListToTagEntityList(List<String> list) {
|
||||
if ( list == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<TagEntity> list1 = new ArrayList<TagEntity>( list.size() );
|
||||
for ( String string : list ) {
|
||||
list1.add( toTag( string ) );
|
||||
}
|
||||
|
||||
return list1;
|
||||
}
|
||||
|
||||
protected List<String> tagEntityListToStringList(List<TagEntity> list) {
|
||||
if ( list == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<String> list1 = new ArrayList<String>( list.size() );
|
||||
for ( TagEntity tagEntity : list ) {
|
||||
list1.add( fromTag( tagEntity ) );
|
||||
}
|
||||
|
||||
return list1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user