Skip to content

Commit 3dfc8e6

Browse files
committed
#23 Clean Code
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
1 parent 928c1d9 commit 3dfc8e6

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/main/java/io/securecodebox/persistence/defectdojo/service/UserProfileService.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import java.util.ArrayList;
1414
import java.util.List;
1515

16-
public class UserProfileService extends GenericDefectDojoService<UserProfile> {
16+
public final class UserProfileService extends GenericDefectDojoService<UserProfile> {
1717

1818
public UserProfileService(Config config) {
1919
super(config);
@@ -31,16 +31,15 @@ protected Class<UserProfile> getModelClass() {
3131

3232
@Override
3333
protected PaginatedResult<UserProfile> deserializeList(String response) throws JsonProcessingException {
34-
// GenericDefectDojoService expects that the response from the defectdojo api is a list
35-
// This endpoint returns a single object though, to not break the code this response gets converted to a defectdojo response
36-
UserProfile userProfile = this.objectMapper.readValue(response, new TypeReference<>() {
34+
/* GenericDefectDojoService expects that the response from the defectdojo api is a list.
35+
* This endpoint returns a single object though, to not break the code this response
36+
* gets converted to a defectdojo response.
37+
*/
38+
final var userProfile = this.objectMapper.readValue(response, new TypeReference<UserProfile>() {
3739
});
38-
List<UserProfile> userProfileList = new ArrayList<>();
39-
userProfileList.add(userProfile);
40-
41-
PaginatedResult<UserProfile> fakeResult = new PaginatedResult<>();
42-
fakeResult.setResults(userProfileList);
43-
fakeResult.setCount(1);
44-
return fakeResult;
40+
final var result = new PaginatedResult<UserProfile>();
41+
result.setResults(List.of(userProfile));
42+
result.setCount(1);
43+
return result;
4544
}
4645
}

0 commit comments

Comments
 (0)