Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use static imports for Collections.singletonList
Browse files Browse the repository at this point in the history
Signed-off-by: currantw <[email protected]>
currantw committed Dec 9, 2024

Verified

This commit was signed with the committer’s verified signature.
ulucinar Alper Rifat Ulucinar
1 parent 7d90cbf commit 823cffe
Showing 92 changed files with 419 additions and 402 deletions.
Original file line number Diff line number Diff line change
@@ -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;
@@ -183,7 +183,7 @@ private void cancel(Cancellable cron) {

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

private String executorName() {
Original file line number Diff line number Diff line change
@@ -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;
@@ -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
@@ -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;

@@ -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;
@@ -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) {
Original file line number Diff line number Diff line change
@@ -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;
@@ -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
@@ -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()));
}

Original file line number Diff line number Diff line change
@@ -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;
@@ -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();
}

/**
@@ -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
Original file line number Diff line number Diff line change
@@ -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;
@@ -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
Original file line number Diff line number Diff line change
@@ -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;
@@ -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;
@@ -99,7 +99,7 @@ public FunctionName convertFunctionName() {

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

@Override
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
@@ -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;
@@ -28,7 +29,7 @@ public class In extends UnresolvedExpression {

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

@Override
Original file line number Diff line number Diff line change
@@ -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;
@@ -29,7 +30,7 @@ public Interval(UnresolvedExpression value, String unit) {

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

@Override
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
@@ -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;
@@ -23,7 +24,7 @@ public class Not extends UnresolvedExpression {

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

@Override
Original file line number Diff line number Diff line change
@@ -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;
@@ -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. */
Original file line number Diff line number Diff line change
@@ -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;
@@ -27,7 +28,7 @@ public UnresolvedArgument(String argName, UnresolvedExpression value) {

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

@Override
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
@@ -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;
@@ -41,7 +42,7 @@ public RareTopN attach(UnresolvedPlan child) {

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

@Override
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
@@ -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;
@@ -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;
}

Loading

0 comments on commit 823cffe

Please sign in to comment.