package ai.verta.modeldb.common.query;

import org.jdbi.v3.core.statement.Query;

import java.util.LinkedList;
import java.util.List;
import java.util.function.Consumer;

public class QueryFilterContext {
  public final List<String> conditions;
  public final List<Consumer<Query>> binds;
  public final List<OrderItem> orderItems;

  public QueryFilterContext() {
    conditions = new LinkedList<>();
    binds = new LinkedList<>();
    orderItems = new LinkedList<>();
  }

  public QueryFilterContext addCondition(String condition) {
    this.conditions.add(condition);
    return this;
  }

  public QueryFilterContext addBind(Consumer<Query> bind) {
    this.binds.add(bind);
    return this;
  }

  public QueryFilterContext addOrderItem(OrderItem item) {
    this.orderItems.add(item);
    return this;
  }

  public QueryFilterContext combine(QueryFilterContext other) {
    this.conditions.addAll(other.conditions);
    this.binds.addAll(other.binds);
    this.orderItems.addAll(other.orderItems);
    return this;
  }

  public static QueryFilterContext combine(List<QueryFilterContext> contexts) {
    var ret = new QueryFilterContext();
    for (final var context : contexts) {
      ret = ret.combine(context);
    }
    return ret;
  }
}
@@ -197,29 +197,30 @@
 ontext %7B%0A  p
-ublic
+rivate
  final List%3C
@@ -238,29 +238,30 @@
 ditions;%0A  p
-ublic
+rivate
  final List%3C
@@ -287,21 +287,22 @@
 nds;%0A  p
-ublic
+rivate
  final L
@@ -468,24 +468,230 @@
 t%3C%3E();%0A  %7D%0A%0A
+  public List%3CString%3E getConditions() %7B%0A    return conditions;%0A  %7D%0A%0A  public List%3CConsumer%3CQuery%3E%3E getBinds() %7B%0A    return binds;%0A  %7D%0A%0A  public List%3COrderItem%3E getOrderItems() %7B%0A    return orderItems;%0A  %7D%0A%0A
   public Que
@@ -1453,8 +1453,9 @@
 t;%0A  %7D%0A%7D
+%0A

Update query context (#2204)