]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8089 Cleanup ComponentTreeQuery 1359/head
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 4 Nov 2016 16:50:32 +0000 (17:50 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 8 Nov 2016 10:12:52 +0000 (11:12 +0100)
sonar-db/src/main/java/org/sonar/db/component/ComponentTreeQuery.java

index dff3bc3144808b3d0574b4a67609b8dd615dfb1e..5405f9cb364cd9dcbd1138c19801e435f6f69bd1 100644 (file)
@@ -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<String> 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<String> 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<String> qualifiers;
-    @CheckForNull
-    private Integer page;
-    @CheckForNull
-    private Integer pageSize;
     private String baseUuid;
-    private List<String> 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<String> 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<String, String> {
-    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);
-    }
   }
 }