| 1 | package com.fwmotion.threescale.cms.mappers; | |
| 2 | ||
| 3 | import com.fwmotion.threescale.cms.model.CmsFile; | |
| 4 | import com.redhat.threescale.rest.cms.model.ModelFile; | |
| 5 | import jakarta.annotation.Nullable; | |
| 6 | import org.mapstruct.Mapper; | |
| 7 | import org.mapstruct.Mapping; | |
| 8 | ||
| 9 | import java.util.Arrays; | |
| 10 | import java.util.Collections; | |
| 11 | import java.util.HashSet; | |
| 12 | import java.util.Set; | |
| 13 | import java.util.stream.Collectors; | |
| 14 | ||
| 15 | @Mapper | |
| 16 | public interface CmsFileMapper { | |
| 17 | ||
| 18 | CmsFile fromRest(ModelFile file); | |
| 19 | ||
| 20 | // title is only the filename without path... not useful | |
| 21 | @Mapping(target = "title", ignore = true) | |
| 22 | // url is the S3 or local filesystem location for 3scale... not useful | |
| 23 | @Mapping(target = "url", ignore = true) | |
| 24 | // attachment (aka, file content) is not held in CmsFile | |
| 25 | @Mapping(target = "attachment", ignore = true) | |
| 26 | ModelFile toRest(CmsFile file); | |
| 27 | ||
| 28 | default Set<String> tagsFromRest(@Nullable String tagList) { | |
| 29 |
2
1. tagsFromRest : removed conditional - replaced equality check with false → KILLED 2. tagsFromRest : removed conditional - replaced equality check with true → KILLED |
if (tagList == null) { |
| 30 | return Collections.emptySet(); | |
| 31 | } | |
| 32 | ||
| 33 |
1
1. tagsFromRest : replaced return value with Collections.emptySet for com/fwmotion/threescale/cms/mappers/CmsFileMapper::tagsFromRest → KILLED |
return new HashSet<>(Arrays.asList(tagList.split("\\s*,\\s*"))); |
| 34 | } | |
| 35 | ||
| 36 | default String tagsToRest(@Nullable Set<String> tags) { | |
| 37 |
2
1. tagsToRest : removed conditional - replaced equality check with true → KILLED 2. tagsToRest : removed conditional - replaced equality check with false → KILLED |
if (tags == null) { |
| 38 | return ""; | |
| 39 | } | |
| 40 | ||
| 41 | // Sort tags so they're in consistent order | |
| 42 |
1
1. tagsToRest : replaced return value with "" for com/fwmotion/threescale/cms/mappers/CmsFileMapper::tagsToRest → KILLED |
return tags.stream() |
| 43 | .sorted() | |
| 44 | .collect(Collectors.joining(",")); | |
| 45 | } | |
| 46 | ||
| 47 | } | |
Mutations | ||
| 29 |
1.1 2.2 |
|
| 33 |
1.1 |
|
| 37 |
1.1 2.2 |
|
| 42 |
1.1 |