Sonar Fixes (#2234)
Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -52,6 +52,7 @@ import org.springframework.util.CollectionUtils;
|
||||
@Slf4j
|
||||
public class RsqlParserValidationOracle implements RsqlValidationOracle {
|
||||
|
||||
@SuppressWarnings("java:S1872") // intentionally don't use class but name - class could be unavailable
|
||||
@Override
|
||||
public ValidationOracleContext suggest(final String rsqlQuery, final int cursorPosition) {
|
||||
final List<SuggestToken> expectedTokens = new ArrayList<>();
|
||||
@@ -149,7 +150,7 @@ public class RsqlParserValidationOracle implements RsqlValidationOracle {
|
||||
final int currentQueryLength = rsqlQuery.length() - 1;
|
||||
final Collection<String> tokenImages = TokenDescription.getTokenImage(TokenDescription.COMPARATOR);
|
||||
return tokenImages.stream().map(tokenImage -> new SuggestToken(currentQueryLength,
|
||||
currentQueryLength + tokenImage.length(), null, tokenImage)).collect(Collectors.toList());
|
||||
currentQueryLength + tokenImage.length(), null, tokenImage)).toList();
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
@@ -213,8 +214,8 @@ public class RsqlParserValidationOracle implements RsqlValidationOracle {
|
||||
}
|
||||
|
||||
private static ParseException findParseException(final Throwable e) {
|
||||
if (e instanceof ParseException) {
|
||||
return (ParseException) e;
|
||||
if (e instanceof ParseException parseException) {
|
||||
return parseException;
|
||||
} else if (e.getCause() != null) {
|
||||
return findParseException(e.getCause());
|
||||
}
|
||||
@@ -306,15 +307,15 @@ public class RsqlParserValidationOracle implements RsqlValidationOracle {
|
||||
final String tokenImageName) {
|
||||
return FIELD_NAMES.stream()
|
||||
.map(field -> new SuggestToken(beginToken, endToken, tokenImageName, field.toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
private static List<SuggestToken> toSubSuggestToken(final int beginToken, final int endToken,
|
||||
final String topToken, final String tokenImageName) {
|
||||
return Arrays.stream(TargetFields.values()).filter(field -> field.toString().equalsIgnoreCase(topToken))
|
||||
.map(TargetFields::getSubEntityAttributes).flatMap(List::stream)
|
||||
.map(subentity -> new SuggestToken(beginToken, endToken, tokenImageName, subentity))
|
||||
.collect(Collectors.toList());
|
||||
.map(subEntity -> new SuggestToken(beginToken, endToken, tokenImageName, subEntity))
|
||||
.toList();
|
||||
}
|
||||
|
||||
private static boolean containsValue(final String imageName) {
|
||||
|
||||
@@ -11,6 +11,9 @@ package org.eclipse.hawkbit.repository.jpa.specifications;
|
||||
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.AbstractJpaNamedEntity_;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaRollout;
|
||||
import org.eclipse.hawkbit.repository.jpa.model.JpaRollout_;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
@@ -19,15 +22,11 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.query.QueryUtils;
|
||||
|
||||
/**
|
||||
* Specifications class for {@link Rollout}s. The class provides Spring Data
|
||||
* JPQL Specifications.
|
||||
* Specifications class for {@link Rollout}s. The class provides Spring Data JPQL Specifications.
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public final class RolloutSpecification {
|
||||
|
||||
private RolloutSpecification() {
|
||||
// utility class
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link Specification} for retrieving {@link Rollout}s by its <code>deleted</code> attribute.
|
||||
*
|
||||
@@ -54,7 +53,7 @@ public final class RolloutSpecification {
|
||||
return (rolloutRoot, query, criteriaBuilder) -> {
|
||||
final String searchTextToLower = searchText.toLowerCase();
|
||||
return criteriaBuilder.and(
|
||||
criteriaBuilder.like(criteriaBuilder.lower(rolloutRoot.get(JpaRollout_.name)), searchTextToLower),
|
||||
criteriaBuilder.like(criteriaBuilder.lower(rolloutRoot.get(AbstractJpaNamedEntity_.name)), searchTextToLower),
|
||||
criteriaBuilder.equal(rolloutRoot.get(JpaRollout_.deleted), isDeleted));
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user