Skip to content

Commit

Permalink
Use static imports for Collections.singletonList
Browse files Browse the repository at this point in the history
Signed-off-by: currantw <[email protected]>
  • Loading branch information
currantw committed Dec 6, 2024
1 parent 646c24e commit d9bb503
Show file tree
Hide file tree
Showing 92 changed files with 419 additions and 402 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

package org.opensearch.sql.spark.cluster;

import static java.util.Collections.singletonList;
import static org.opensearch.sql.spark.data.constants.SparkConstants.SPARK_REQUEST_BUFFER_INDEX_NAME;

import com.google.common.annotations.VisibleForTesting;
import java.time.Clock;
import java.time.Duration;
import java.util.Collections;
import java.util.List;
import org.opensearch.client.Client;
import org.opensearch.cluster.LocalNodeClusterManagerListener;
Expand Down Expand Up @@ -183,7 +183,7 @@ private void cancel(Cancellable cron) {

@VisibleForTesting
public List<Cancellable> getFlintIndexRetentionCron() {
return Collections.singletonList(flintIndexRetentionCron);
return singletonList(flintIndexRetentionCron);
}

private String executorName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

package org.opensearch.sql.common.interceptors;

import java.util.Collections;
import static java.util.Collections.singletonList;

import lombok.SneakyThrows;
import okhttp3.Credentials;
import okhttp3.Interceptor;
Expand Down Expand Up @@ -47,7 +48,7 @@ void testIntercept() {
Mockito.verify(chain).proceed(requestArgumentCaptor.capture());
Request request = requestArgumentCaptor.getValue();
Assertions.assertEquals(
Collections.singletonList(Credentials.basic("testAdmin", "testPassword")),
singletonList(Credentials.basic("testAdmin", "testPassword")),
request.headers("Authorization"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package org.opensearch.sql.analysis;

import static java.util.Collections.singletonList;
import static org.opensearch.sql.ast.dsl.AstDSL.and;
import static org.opensearch.sql.ast.dsl.AstDSL.compare;

Expand All @@ -13,7 +14,6 @@
import com.google.common.collect.ImmutableSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -83,9 +83,7 @@ public Expression visitCast(Cast node, AnalysisContext context) {
final Expression expression = node.getExpression().accept(this, context);
return (Expression)
repository.compile(
context.getFunctionProperties(),
node.convertFunctionName(),
Collections.singletonList(expression));
context.getFunctionProperties(), node.convertFunctionName(), singletonList(expression));
}

public ExpressionAnalyzer(BuiltinFunctionRepository repository) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

package org.opensearch.sql.analysis;

import static java.util.Collections.singletonList;

import com.google.common.collect.ImmutableList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -54,7 +55,7 @@ public List<NamedExpression> analyze(

@Override
public List<NamedExpression> visitField(Field node, AnalysisContext context) {
return Collections.singletonList(DSL.named(node.accept(expressionAnalyzer, context)));
return singletonList(DSL.named(node.accept(expressionAnalyzer, context)));
}

@Override
Expand All @@ -65,7 +66,7 @@ public List<NamedExpression> visitAlias(Alias node, AnalysisContext context) {
}

Expression expr = referenceIfSymbolDefined(node, context);
return Collections.singletonList(
return singletonList(
DSL.named(unqualifiedNameIfFieldOnly(node, context), expr, node.getAlias()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

package org.opensearch.sql.ast.expression;

import java.util.Collections;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;

import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand Down Expand Up @@ -42,7 +44,7 @@ public class AggregateFunction extends UnresolvedExpression {
public AggregateFunction(String funcName, UnresolvedExpression field) {
this.funcName = funcName;
this.field = field;
this.argList = Collections.emptyList();
this.argList = emptyList();
}

/**
Expand All @@ -55,13 +57,13 @@ public AggregateFunction(String funcName, UnresolvedExpression field) {
public AggregateFunction(String funcName, UnresolvedExpression field, Boolean distinct) {
this.funcName = funcName;
this.field = field;
this.argList = Collections.emptyList();
this.argList = emptyList();
this.distinct = distinct;
}

@Override
public List<UnresolvedExpression> getChild() {
return Collections.singletonList(field);
return singletonList(field);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

package org.opensearch.sql.ast.expression;

import java.util.Collections;
import static java.util.Collections.singletonList;

import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand All @@ -25,7 +26,7 @@ public class Argument extends UnresolvedExpression {
// private final DataType valueType;
@Override
public List<UnresolvedExpression> getChild() {
return Collections.singletonList(value);
return singletonList(value);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package org.opensearch.sql.ast.expression;

import static java.util.Collections.singletonList;
import static org.opensearch.sql.expression.function.BuiltinFunctionName.CAST_TO_BOOLEAN;
import static org.opensearch.sql.expression.function.BuiltinFunctionName.CAST_TO_BYTE;
import static org.opensearch.sql.expression.function.BuiltinFunctionName.CAST_TO_DATE;
Expand All @@ -19,7 +20,6 @@
import static org.opensearch.sql.expression.function.BuiltinFunctionName.CAST_TO_TIMESTAMP;

import com.google.common.collect.ImmutableMap;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
Expand Down Expand Up @@ -99,7 +99,7 @@ public FunctionName convertFunctionName() {

@Override
public List<? extends Node> getChild() {
return Collections.singletonList(expression);
return singletonList(expression);
}

@Override
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/org/opensearch/sql/ast/expression/In.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

package org.opensearch.sql.ast.expression;

import java.util.Collections;
import static java.util.Collections.singletonList;

import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand All @@ -28,7 +29,7 @@ public class In extends UnresolvedExpression {

@Override
public List<UnresolvedExpression> getChild() {
return Collections.singletonList(field);
return singletonList(field);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

package org.opensearch.sql.ast.expression;

import java.util.Collections;
import static java.util.Collections.singletonList;

import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand All @@ -29,7 +30,7 @@ public Interval(UnresolvedExpression value, String unit) {

@Override
public List<UnresolvedExpression> getChild() {
return Collections.singletonList(value);
return singletonList(value);
}

@Override
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/org/opensearch/sql/ast/expression/Not.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

package org.opensearch.sql.ast.expression;

import java.util.Collections;
import static java.util.Collections.singletonList;

import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand All @@ -23,7 +24,7 @@ public class Not extends UnresolvedExpression {

@Override
public List<UnresolvedExpression> getChild() {
return Collections.singletonList(expression);
return singletonList(expression);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

package org.opensearch.sql.ast.expression;

import static java.util.Collections.singletonList;
import static java.util.Objects.requireNonNull;
import static java.util.stream.Collectors.toList;

import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.StreamSupport;
Expand All @@ -25,7 +25,7 @@ public class QualifiedName extends UnresolvedExpression {
private final List<String> parts;

public QualifiedName(String name) {
this.parts = Collections.singletonList(name);
this.parts = singletonList(name);
}

/** QualifiedName Constructor. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

package org.opensearch.sql.ast.expression;

import java.util.Collections;
import static java.util.Collections.singletonList;

import java.util.List;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand All @@ -27,7 +28,7 @@ public UnresolvedArgument(String argName, UnresolvedExpression value) {

@Override
public List<UnresolvedExpression> getChild() {
return Collections.singletonList(value);
return singletonList(value);
}

@Override
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/org/opensearch/sql/ast/tree/RareTopN.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

package org.opensearch.sql.ast.tree;

import java.util.Collections;
import static java.util.Collections.singletonList;

import java.util.List;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
Expand Down Expand Up @@ -41,7 +42,7 @@ public RareTopN attach(UnresolvedPlan child) {

@Override
public List<UnresolvedPlan> getChild() {
return Collections.singletonList(this.child);
return singletonList(this.child);
}

@Override
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/org/opensearch/sql/ast/tree/Relation.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

package org.opensearch.sql.ast.tree;

import static java.util.Collections.singletonList;

import com.google.common.collect.ImmutableList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import lombok.AllArgsConstructor;
Expand All @@ -32,7 +33,7 @@ public Relation(UnresolvedExpression tableName) {
}

public Relation(UnresolvedExpression tableName, String alias) {
this.tableName = Collections.singletonList(tableName);
this.tableName = singletonList(tableName);
this.alias = alias;
}

Expand Down
Loading

0 comments on commit d9bb503

Please sign in to comment.