Use field injection, but suppress SQ Bugs.

We need this b/c of MapStruct
This commit is contained in:
Philipp Czora
2018-06-25 15:17:53 +02:00
parent 3d450ece64
commit 716d7ab7fc
4 changed files with 18 additions and 16 deletions

View File

@@ -16,18 +16,15 @@ import static de.otto.edison.hal.Links.linkingTo;
import static sonia.scm.api.v2.resources.ResourceLinks.group;
import static sonia.scm.api.v2.resources.ResourceLinks.user;
/**
* Mapstruct does not support parameterized (i.e. non-default) constructors. Thus, we need to use field injection.
*/
@java.lang.SuppressWarnings("squid:S3306")
@Mapper
public abstract class GroupToGroupDtoMapper extends BaseMapper<Group, GroupDto> {
private UriInfoStore uriInfoStore;
GroupToGroupDtoMapper() {
}
@Inject
public GroupToGroupDtoMapper(UriInfoStore uriInfoStore) {
this.uriInfoStore = uriInfoStore;
}
private UriInfoStore uriInfoStore;
@AfterMapping
void appendLinks(Group group, @MappingTarget GroupDto target) {

View File

@@ -7,6 +7,10 @@ import javax.inject.Inject;
import static sonia.scm.api.v2.resources.ResourceLinks.userCollection;
/**
* Mapstruct does not support parameterized (i.e. non-default) constructors. Thus, we need to use field injection.
*/
@java.lang.SuppressWarnings("squid:S3306")
public class UserCollectionToDtoMapper extends BasicCollectionToDtoMapper<User, UserDto> {
private final UriInfoStore uriInfoStore;

View File

@@ -8,18 +8,15 @@ import javax.inject.Inject;
import static sonia.scm.api.rest.resources.UserResource.DUMMY_PASSWORT;
/**
* Mapstruct does not support parameterized (i.e. non-default) constructors. Thus, we need to use field injection.
*/
@java.lang.SuppressWarnings("squid:S3306")
@Mapper
public abstract class UserDtoToUserMapper {
private PasswordService passwordService;
UserDtoToUserMapper() {
}
@Inject
public UserDtoToUserMapper(PasswordService passwordService) {
this.passwordService = passwordService;
}
private PasswordService passwordService;
@Mappings({
@Mapping(source = "password", target = "password", qualifiedByName = "encrypt"),

View File

@@ -14,6 +14,10 @@ import static de.otto.edison.hal.Link.link;
import static de.otto.edison.hal.Links.linkingTo;
import static sonia.scm.api.v2.resources.ResourceLinks.user;
/**
* Mapstruct does not support parameterized (i.e. non-default) constructors. Thus, we need to use field injection.
*/
@java.lang.SuppressWarnings("squid:S3306")
@Mapper
public abstract class UserToUserDtoMapper extends BaseMapper<User, UserDto> {