All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.scalar.db.sql.statement.builder.StatementBuilderUtils Maven / Gradle / Ivy

There is a newer version: 3.14.0
Show newest version
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());
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy