com.scalar.db.sql.statement.builder.StatementBuilderUtils Maven / Gradle / Ivy
package com.scalar.db.sql.statement.builder;
import com.google.common.collect.ImmutableList;
import com.scalar.db.sql.AndPredicateList;
import com.scalar.db.sql.OrPredicateList;
import com.scalar.db.sql.Predicate;
import javax.annotation.Nullable;
public final class StatementBuilderUtils {
private StatementBuilderUtils() {}
public static ImmutableList buildAndPredicateLists(
@Nullable Predicate predicate,
ImmutableList.Builder andPredicateListsBuilder) {
if (predicate != null) {
return ImmutableList.of(AndPredicateList.predicate(predicate).build());
}
return andPredicateListsBuilder.build().stream()
.filter(andPredicateList -> !andPredicateList.predicates.isEmpty())
.collect(ImmutableList.toImmutableList());
}
public static ImmutableList buildOrPredicateLists(
ImmutableList.Builder orPredicateListsBuilder) {
return orPredicateListsBuilder.build().stream()
.filter(orPredicateList -> !orPredicateList.predicates.isEmpty())
.collect(ImmutableList.toImmutableList());
}
}