From f9c7367366926ef82c4a8031debf6d77a1fae1d4 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Fri, 4 Nov 2016 17:50:32 +0100 Subject: [PATCH] SONAR-8089 Cleanup ComponentTreeQuery --- .../db/component/ComponentTreeQuery.java | 92 ------------------- 1 file changed, 92 deletions(-) diff --git a/sonar-db/src/main/java/org/sonar/db/component/ComponentTreeQuery.java b/sonar-db/src/main/java/org/sonar/db/component/ComponentTreeQuery.java index dff3bc31448..5405f9cb364 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/ComponentTreeQuery.java +++ b/sonar-db/src/main/java/org/sonar/db/component/ComponentTreeQuery.java @@ -21,18 +21,12 @@ package org.sonar.db.component; import java.util.ArrayList; import java.util.Collection; -import java.util.List; import java.util.Locale; -import java.util.function.Function; -import java.util.stream.Collectors; import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.sonar.db.WildcardPosition; -import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.collect.Lists.newArrayList; -import static java.lang.String.format; import static java.util.Objects.requireNonNull; import static org.sonar.db.DatabaseUtils.buildLikeValue; import static org.sonar.db.WildcardPosition.AFTER; @@ -48,24 +42,14 @@ public class ComponentTreeQuery { // SONAR-7681 a public implementation of List must be used in MyBatis - potential concurrency exceptions otherwise @CheckForNull private final ArrayList qualifiers; - @CheckForNull - private final Integer page; - @CheckForNull - private final Integer pageSize; private final String baseUuid; - private final String sqlSort; - private final String direction; private final Strategy strategy; private ComponentTreeQuery(Builder builder) { this.nameOrKeyQuery = builder.nameOrKeyQuery; this.qualifiers = builder.qualifiers == null ? null : newArrayList(builder.qualifiers); - this.page = builder.page; - this.pageSize = builder.pageSize; this.baseUuid = builder.baseUuid; this.strategy = requireNonNull(builder.strategy); - this.direction = builder.asc ? "ASC" : "DESC"; - this.sqlSort = builder.sortFields != null ? sortFieldsToSqlSort(builder.sortFields, direction) : null; } @CheckForNull @@ -83,16 +67,6 @@ public class ComponentTreeQuery { return nameOrKeyQuery == null ? null : buildLikeValue(nameOrKeyQuery, AFTER).toLowerCase(Locale.ENGLISH); } - @Deprecated - public Integer getPage() { - return page; - } - - @Deprecated - public Integer getPageSize() { - return pageSize; - } - public String getBaseUuid() { return baseUuid; } @@ -101,16 +75,6 @@ public class ComponentTreeQuery { return strategy; } - @Deprecated - public String getSqlSort() { - return sqlSort; - } - - @Deprecated - public String getDirection() { - return direction; - } - public String getUuidPath(ComponentDto component) { switch (strategy) { case CHILDREN: @@ -126,26 +90,12 @@ public class ComponentTreeQuery { return new Builder(); } - @Deprecated - private static String sortFieldsToSqlSort(List sortFields, String direction) { - return sortFields - .stream() - .map(new SortFieldToSqlSortFieldFunction(direction)::apply) - .collect(Collectors.joining(", ")); - } - public static class Builder { @CheckForNull private String nameOrKeyQuery; @CheckForNull private Collection qualifiers; - @CheckForNull - private Integer page; - @CheckForNull - private Integer pageSize; private String baseUuid; - private List sortFields; - private boolean asc = true; private Strategy strategy; private Builder() { @@ -167,18 +117,6 @@ public class ComponentTreeQuery { return this; } - @Deprecated - public Builder setPage(int page) { - this.page = page; - return this; - } - - @Deprecated - public Builder setPageSize(int pageSize) { - this.pageSize = pageSize; - return this; - } - public Builder setBaseUuid(String uuid) { this.baseUuid = uuid; return this; @@ -188,35 +126,5 @@ public class ComponentTreeQuery { this.strategy = requireNonNull(strategy); return this; } - - @Deprecated - public Builder setSortFields(List sorts) { - checkArgument(sorts != null && !sorts.isEmpty()); - this.sortFields = sorts; - return this; - } - - @Deprecated - public Builder setAsc(boolean asc) { - this.asc = asc; - return this; - } - } - - @Deprecated - private static class SortFieldToSqlSortFieldFunction implements Function { - private static final String PATTERN = "LOWER(p.%1$s) %2$s, p.%1$s %2$s"; - - private final String direction; - - private SortFieldToSqlSortFieldFunction(String direction) { - this.direction = direction; - } - - @Nonnull - @Override - public String apply(@Nonnull String input) { - return format(PATTERN, input, direction); - } } } -- 2.39.5