Fix sonar findings on 21 style (#3020)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2026-04-15 16:57:10 +03:00
committed by GitHub
parent 643e96b7b1
commit 82ee1cc4e6
12 changed files with 284 additions and 273 deletions

View File

@@ -255,9 +255,8 @@ public final class TargetView extends TableView<TargetView.TargetWithDs, String>
}
private static List<MgmtTargetFilterQuery> listFilters(HawkbitMgmtClient hawkbitClient) {
return Optional.ofNullable(hawkbitClient.getTargetFilterQueryRestApi()
.getFilters(null, 0, 30, null, null).getBody())
.map(PagedList<MgmtTargetFilterQuery>::getContent)
return Optional.ofNullable(hawkbitClient.getTargetFilterQueryRestApi().getFilters(null, 0, 30, null, null).getBody())
.map(PagedList::getContent)
.orElseGet(List::of);
}

View File

@@ -149,18 +149,18 @@ public final class Filter extends Div {
return null;
}
if (value instanceof Collection<?> coll) {
final StringBuilder sb = new StringBuilder();
coll.stream().forEach(next -> sb.append(key).append("==").append(next).append(','));
return sb.substring(0, sb.length() - 1);
} else if (value instanceof Optional<?> opt) {
if (opt.isEmpty()) {
return null;
} else {
return key + "==" + opt.get();
switch (value) {
case Collection<?> coll -> {
final StringBuilder sb = new StringBuilder();
coll.stream().forEach(next -> sb.append(key).append("==").append(next).append(','));
return sb.substring(0, sb.length() - 1);
}
case Optional<?> opt -> {
return opt.map(o -> key + "==" + o).orElse(null);
}
default -> {
return key + "==" + value;
}
} else {
return key + "==" + value;
}
}