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

io.stargate.sgv2.common.cql.builder.QueryBuilderImpl Maven / Gradle / Ivy

There is a newer version: 2.0.0-BETA-4
Show newest version
/*
 * Copyright DataStax, Inc. and/or The Stargate Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.stargate.sgv2.common.cql.builder;

import static java.lang.String.format;

import com.github.misberner.apcommons.util.AFModifier;
import com.github.misberner.duzzt.annotations.DSLAction;
import com.github.misberner.duzzt.annotations.GenerateEmbeddedDSL;
import com.github.misberner.duzzt.annotations.SubExpr;
import io.stargate.bridge.proto.QueryOuterClass.BatchQuery;
import io.stargate.bridge.proto.QueryOuterClass.Query;
import io.stargate.bridge.proto.QueryOuterClass.QueryParameters;
import io.stargate.bridge.proto.QueryOuterClass.Value;
import io.stargate.bridge.proto.QueryOuterClass.Values;
import io.stargate.sgv2.common.cql.ColumnUtils;
import io.stargate.sgv2.common.cql.CqlStrings;
import io.stargate.sgv2.common.grpc.StargateBridgeClient;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Convenience builder for creating queries.
 *
 * 

The generated CQL string is wrapped into a {@link Query} that can be passed directly to {@link * StargateBridgeClient#executeQuery(Query)}. In addition, any time a {@link Value} is passed to the * builder (via such methods as {@link #where(Column, Predicate, Object)}, {@link #value(Column, * Object)}, etc.), it is automatically replaced with a bind marker, and stored in {@link * Query#getValues()}. */ @GenerateEmbeddedDSL( modifier = AFModifier.DEFAULT, autoVarArgs = false, name = "QueryBuilder", syntax = "(|

||||