Skip to content

Instantly share code, notes, and snippets.

@httpmurilo
Created February 10, 2022 00:08
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 httpmurilo/8d651463987e9cf73daf19af9940e8c1 to your computer and use it in GitHub Desktop.
Save httpmurilo/8d651463987e9cf73daf19af9940e8c1 to your computer and use it in GitHub Desktop.
package io.httpmurilo.sales.mapper;
import io.httpmurilo.sales.dto.UserDTO;
import io.httpmurilo.sales.entity.User;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@Mapper(componentModel = "spring") //define que é um Spring bean e pode ser injetado via @Autowired
public abstract class UserMapper { //impedimos de instanciar diretamente
public static final UserMapper INSTANCE = Mappers.getMapper(UserMapper.class); //singleton
public abstract User toUser(UserDTO dto);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment