Skip to content

Commit

Permalink
Replace Collections.singletonList with List.of
Browse files Browse the repository at this point in the history
Signed-off-by: currantw <[email protected]>
  • Loading branch information
currantw committed Dec 9, 2024
1 parent 823cffe commit 74bbe73
Show file tree
Hide file tree
Showing 99 changed files with 285 additions and 426 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

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;
Expand Down Expand Up @@ -183,7 +182,7 @@ private void cancel(Cancellable cron) {

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

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

package org.opensearch.sql.common.interceptors;

import static java.util.Collections.singletonList;

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

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 Down Expand Up @@ -83,7 +82,7 @@ public Expression visitCast(Cast node, AnalysisContext context) {
final Expression expression = node.getExpression().accept(this, context);
return (Expression)
repository.compile(
context.getFunctionProperties(), node.convertFunctionName(), singletonList(expression));
context.getFunctionProperties(), node.convertFunctionName(), List.of(expression));
}

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

package org.opensearch.sql.analysis;

import static java.util.Collections.singletonList;

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

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

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

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package org.opensearch.sql.ast.expression;

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

import java.util.List;
import lombok.EqualsAndHashCode;
Expand Down Expand Up @@ -63,7 +62,7 @@ public AggregateFunction(String funcName, UnresolvedExpression field, Boolean di

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

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

package org.opensearch.sql.ast.expression;

import static java.util.Collections.singletonList;

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

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

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 Down Expand Up @@ -99,7 +98,7 @@ public FunctionName convertFunctionName() {

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

@Override
Expand Down
4 changes: 1 addition & 3 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,8 +5,6 @@

package org.opensearch.sql.ast.expression;

import static java.util.Collections.singletonList;

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

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

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

package org.opensearch.sql.ast.expression;

import static java.util.Collections.singletonList;

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

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

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

package org.opensearch.sql.ast.expression;

import static java.util.Collections.singletonList;

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

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

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

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;

Expand All @@ -25,7 +24,7 @@ public class QualifiedName extends UnresolvedExpression {
private final List<String> parts;

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

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

package org.opensearch.sql.ast.expression;

import static java.util.Collections.singletonList;

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

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

@Override
Expand Down
4 changes: 1 addition & 3 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,8 +5,6 @@

package org.opensearch.sql.ast.tree;

import static java.util.Collections.singletonList;

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

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

@Override
Expand Down
4 changes: 1 addition & 3 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,6 @@

package org.opensearch.sql.ast.tree;

import static java.util.Collections.singletonList;

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

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

Expand Down
Loading

0 comments on commit 74bbe73

Please sign in to comment.